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
20587f1e
Commit
20587f1e
authored
Dec 28, 2021
by
finswimmer
Committed by
Bjorn Neergaard
Jan 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace existing dependency when adding dependency with version constraint
parent
ecb030e1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
src/poetry/console/commands/add.py
+8
-0
tests/console/commands/test_add.py
+47
-0
No files found.
src/poetry/console/commands/add.py
View file @
20587f1e
import
contextlib
from
typing
import
Dict
from
typing
import
List
...
...
@@ -203,6 +205,12 @@ You can specify a package in the following forms:
constraint
=
constraint
[
"version"
]
section
[
_constraint
[
"name"
]]
=
constraint
with
contextlib
.
suppress
(
ValueError
):
self
.
poetry
.
package
.
dependency_group
(
group
)
.
remove_dependency
(
_constraint
[
"name"
]
)
self
.
poetry
.
package
.
add_dependency
(
Factory
.
create_dependency
(
_constraint
[
"name"
],
...
...
tests/console/commands/test_add.py
View file @
20587f1e
...
...
@@ -67,6 +67,53 @@ Package operations: 1 install, 0 updates, 0 removals
assert
content
[
"dependencies"
][
"cachy"
]
==
"^0.2.0"
def
test_add_replace_by_constraint
(
app
:
"PoetryTestApplication"
,
repo
:
"TestRepository"
,
tester
:
"CommandTester"
):
repo
.
add_package
(
get_package
(
"cachy"
,
"0.1.0"
))
repo
.
add_package
(
get_package
(
"cachy"
,
"0.2.0"
))
tester
.
execute
(
"cachy"
)
expected
=
"""
\
Using version ^0.2.0 for cachy
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 1 install, 0 updates, 0 removals
• Installing cachy (0.2.0)
"""
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
command
.
installer
.
executor
.
installations_count
==
1
content
=
app
.
poetry
.
file
.
read
()[
"tool"
][
"poetry"
]
assert
"cachy"
in
content
[
"dependencies"
]
assert
content
[
"dependencies"
][
"cachy"
]
==
"^0.2.0"
tester
.
execute
(
"cachy@0.1.0"
)
expected
=
"""
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 1 install, 0 updates, 0 removals
• Installing cachy (0.1.0)
"""
assert
tester
.
io
.
fetch_output
()
==
expected
content
=
app
.
poetry
.
file
.
read
()[
"tool"
][
"poetry"
]
assert
"cachy"
in
content
[
"dependencies"
]
assert
content
[
"dependencies"
][
"cachy"
]
==
"0.1.0"
def
test_add_no_constraint_editable_error
(
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