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
434e5409
Unverified
Commit
434e5409
authored
Jul 24, 2018
by
Sébastien Eustace
Committed by
Sébastien Eustace
Jul 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix adding dependency to missing section
Issue #61
parent
ad834e29
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
poetry/console/commands/add.py
+3
-0
tests/console/commands/test_add.py
+35
-0
tests/fixtures/simple_project/pyproject.toml
+0
-2
No files found.
poetry/console/commands/add.py
View file @
434e5409
...
@@ -54,6 +54,9 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -54,6 +54,9 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
content
=
self
.
poetry
.
file
.
read
()
content
=
self
.
poetry
.
file
.
read
()
poetry_content
=
content
[
"tool"
][
"poetry"
]
poetry_content
=
content
[
"tool"
][
"poetry"
]
if
section
not
in
poetry_content
:
poetry_content
[
section
]
=
{}
for
name
in
packages
:
for
name
in
packages
:
for
key
in
poetry_content
[
section
]:
for
key
in
poetry_content
[
section
]:
if
key
.
lower
()
==
name
.
lower
():
if
key
.
lower
()
==
name
.
lower
():
...
...
tests/console/commands/test_add.py
View file @
434e5409
...
@@ -382,3 +382,38 @@ Writing lock file
...
@@ -382,3 +382,38 @@ Writing lock file
"version"
:
"0.2.0"
,
"version"
:
"0.2.0"
,
"platform"
:
platform
,
"platform"
:
platform
,
}
}
def
test_add_to_section_that_does_no_exist_yet
(
app
,
repo
,
installer
):
command
=
app
.
find
(
"add"
)
tester
=
CommandTester
(
command
)
repo
.
add_package
(
get_package
(
"cachy"
,
"0.1.0"
))
repo
.
add_package
(
get_package
(
"cachy"
,
"0.2.0"
))
tester
.
execute
(
[(
"command"
,
command
.
get_name
()),
(
"name"
,
[
"cachy"
]),
(
"--dev"
,
True
)]
)
expected
=
"""
\
Using version ^0.2.0 for cachy
Updating dependencies
Resolving dependencies...
Package operations: 1 install, 0 updates, 0 removals
Writing lock file
- Installing cachy (0.2.0)
"""
assert
tester
.
get_display
(
True
)
==
expected
assert
len
(
installer
.
installs
)
==
1
content
=
app
.
poetry
.
file
.
read
()[
"tool"
][
"poetry"
]
assert
"cachy"
in
content
[
"dev-dependencies"
]
assert
content
[
"dev-dependencies"
][
"cachy"
]
==
"^0.2.0"
tests/fixtures/simple_project/pyproject.toml
View file @
434e5409
...
@@ -23,5 +23,3 @@ classifiers = [
...
@@ -23,5 +23,3 @@ classifiers = [
# Requirements
# Requirements
[tool.poetry.dependencies]
[tool.poetry.dependencies]
python
=
"~2.7 || ^3.6"
python
=
"~2.7 || ^3.6"
[tool.poetry.dev-dependencies]
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