Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
2ca2080c
Commit
2ca2080c
authored
May 23, 2022
by
Mathieu Kniewallner
Committed by
Arun Babu Neelicattu
May 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(commands/add): canonicalize package name when looking for existing packages
parent
a9fade8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
+27
-1
src/poetry/console/commands/add.py
+3
-1
tests/console/commands/test_add.py
+24
-0
No files found.
src/poetry/console/commands/add.py
View file @
2ca2080c
...
...
@@ -9,6 +9,8 @@ from cleo.helpers import argument
from
cleo.helpers
import
option
from
tomlkit.toml_document
import
TOMLDocument
from
poetry.utils.helpers
import
canonicalize_name
try
:
from
poetry.core.packages.dependency_group
import
MAIN_GROUP
...
...
@@ -268,7 +270,7 @@ You can specify a package in the following forms:
for
name
in
packages
:
for
key
in
section
:
if
key
.
lower
()
==
name
.
lower
(
):
if
canonicalize_name
(
key
)
==
canonicalize_name
(
name
):
existing_packages
.
append
(
name
)
return
existing_packages
...
...
tests/console/commands/test_add.py
View file @
2ca2080c
...
...
@@ -940,6 +940,30 @@ If you prefer to upgrade it to the latest available version,\
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_add_should_skip_when_adding_canonicalized_existing_package_with_no_constraint
(
app
:
PoetryTestApplication
,
repo
:
TestRepository
,
tester
:
CommandTester
):
content
=
app
.
poetry
.
file
.
read
()
content
[
"tool"
][
"poetry"
][
"dependencies"
][
"foo-bar"
]
=
"^1.0"
app
.
poetry
.
file
.
write
(
content
)
repo
.
add_package
(
get_package
(
"foo-bar"
,
"1.1.2"
))
tester
.
execute
(
"Foo_Bar"
)
expected
=
"""
\
The following packages are already present in the pyproject.toml and will be skipped:
• Foo_Bar
If you want to update it to the latest compatible version,
\
you can use `poetry update package`.
If you prefer to upgrade it to the latest available version,
\
you can use `poetry add package@latest`.
"""
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_add_should_work_when_adding_existing_package_with_latest_constraint
(
app
:
PoetryTestApplication
,
repo
:
TestRepository
,
tester
:
CommandTester
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment