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
689b9afe
Commit
689b9afe
authored
Oct 18, 2022
by
finswimmer
Committed by
Bjorn Neergaard
Nov 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: ensure no duplicate package names are stored in pyproject.toml
parent
5b10800e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
src/poetry/console/commands/add.py
+8
-0
tests/console/commands/test_add.py
+38
-0
No files found.
src/poetry/console/commands/add.py
View file @
689b9afe
...
@@ -215,6 +215,14 @@ The add command adds required packages to your <comment>pyproject.toml</> and in
...
@@ -215,6 +215,14 @@ The add command adds required packages to your <comment>pyproject.toml</> and in
constraint_name
=
_constraint
[
"name"
]
constraint_name
=
_constraint
[
"name"
]
assert
isinstance
(
constraint_name
,
str
)
assert
isinstance
(
constraint_name
,
str
)
canonical_constraint_name
=
canonicalize_name
(
constraint_name
)
for
key
in
section
:
if
canonicalize_name
(
key
)
==
canonical_constraint_name
:
section
[
key
]
=
constraint
break
else
:
section
[
constraint_name
]
=
constraint
section
[
constraint_name
]
=
constraint
with
contextlib
.
suppress
(
ValueError
):
with
contextlib
.
suppress
(
ValueError
):
...
...
tests/console/commands/test_add.py
View file @
689b9afe
...
@@ -1055,6 +1055,44 @@ If you prefer to upgrade it to the latest available version,\
...
@@ -1055,6 +1055,44 @@ If you prefer to upgrade it to the latest available version,\
assert
expected
in
tester
.
io
.
fetch_output
()
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_add_latest_should_not_create_duplicate_keys
(
project_factory
:
ProjectFactory
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
):
pyproject_content
=
"""
\
[tool.poetry]
name = "simple-project"
version = "1.2.3"
description = "Some description."
authors = [
"Python Poetry <tests@python-poetry.org>"
]
license = "MIT"
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.6"
Foo = "^0.6"
"""
poetry
=
project_factory
(
name
=
"simple-project"
,
pyproject_content
=
pyproject_content
)
content
=
poetry
.
file
.
read
()
assert
"Foo"
in
content
[
"tool"
][
"poetry"
][
"dependencies"
]
assert
content
[
"tool"
][
"poetry"
][
"dependencies"
][
"Foo"
]
==
"^0.6"
assert
"foo"
not
in
content
[
"tool"
][
"poetry"
][
"dependencies"
]
tester
=
command_tester_factory
(
"add"
,
poetry
=
poetry
)
repo
.
add_package
(
get_package
(
"foo"
,
"1.1.2"
))
tester
.
execute
(
"foo@latest"
)
updated_content
=
poetry
.
file
.
read
()
assert
"Foo"
in
updated_content
[
"tool"
][
"poetry"
][
"dependencies"
]
assert
updated_content
[
"tool"
][
"poetry"
][
"dependencies"
][
"Foo"
]
==
"^1.1.2"
assert
"foo"
not
in
updated_content
[
"tool"
][
"poetry"
][
"dependencies"
]
def
test_add_should_work_when_adding_existing_package_with_latest_constraint
(
def
test_add_should_work_when_adding_existing_package_with_latest_constraint
(
app
:
PoetryTestApplication
,
repo
:
TestRepository
,
tester
:
CommandTester
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