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
1b795033
Unverified
Commit
1b795033
authored
May 28, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix add and init in a cleaner way
parent
f0bb4970
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
21 deletions
+18
-21
poetry/console/commands/add.py
+0
-3
poetry/console/commands/init.py
+12
-14
tests/console/commands/test_init.py
+6
-4
No files found.
poetry/console/commands/add.py
View file @
1b795033
...
@@ -29,9 +29,6 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -29,9 +29,6 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
'poetry.repositories.pypi_repository'
'poetry.repositories.pypi_repository'
]
]
def
initialize
(
self
,
i
,
o
):
super
(
AddCommand
,
self
)
.
initialize
(
i
,
o
)
def
handle
(
self
):
def
handle
(
self
):
from
poetry.installation
import
Installer
from
poetry.installation
import
Installer
from
poetry.semver
import
parse_constraint
from
poetry.semver
import
parse_constraint
...
...
poetry/console/commands/init.py
View file @
1b795033
...
@@ -7,6 +7,7 @@ from typing import List
...
@@ -7,6 +7,7 @@ from typing import List
from
typing
import
Tuple
from
typing
import
Tuple
from
.command
import
Command
from
.command
import
Command
from
.venv_command
import
VenvCommand
class
InitCommand
(
Command
):
class
InitCommand
(
Command
):
...
@@ -31,17 +32,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
...
@@ -31,17 +32,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
def
__init__
(
self
):
def
__init__
(
self
):
super
(
InitCommand
,
self
)
.
__init__
()
super
(
InitCommand
,
self
)
.
__init__
()
self
.
pool
=
None
self
.
_pool
=
None
def
initialize
(
self
,
i
,
o
):
from
poetry.repositories
import
Pool
from
poetry.repositories.pypi_repository
import
PyPiRepository
super
(
InitCommand
,
self
)
.
initialize
(
i
,
o
)
if
self
.
pool
is
None
:
self
.
pool
=
Pool
()
self
.
pool
.
add_repository
(
PyPiRepository
())
def
handle
(
self
):
def
handle
(
self
):
from
poetry.layouts
import
layout
from
poetry.layouts
import
layout
...
@@ -326,7 +317,14 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
...
@@ -326,7 +317,14 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
return
author
return
author
def
_get_pool
(
self
):
def
_get_pool
(
self
):
if
self
.
pool
is
None
:
from
poetry.repositories
import
Pool
self
.
pool
=
self
.
poetry
.
pool
from
poetry.repositories.pypi_repository
import
PyPiRepository
if
isinstance
(
self
,
VenvCommand
):
return
self
.
poetry
.
pool
if
self
.
_pool
is
None
:
self
.
_pool
=
Pool
()
self
.
_pool
.
add_repository
(
PyPiRepository
())
return
self
.
pool
return
self
.
_
pool
tests/console/commands/test_init.py
View file @
1b795033
...
@@ -18,8 +18,10 @@ def tmp_dir():
...
@@ -18,8 +18,10 @@ def tmp_dir():
shutil
.
rmtree
(
dir_
)
shutil
.
rmtree
(
dir_
)
def
test_basic_interactive
(
app
,
mocker
):
def
test_basic_interactive
(
app
,
mocker
,
poetry
):
command
=
app
.
find
(
'init'
)
command
=
app
.
find
(
'init'
)
command
.
_pool
=
poetry
.
pool
mocker
.
patch
(
'poetry.utils._compat.Path.open'
)
mocker
.
patch
(
'poetry.utils._compat.Path.open'
)
p
=
mocker
.
patch
(
'poetry.utils._compat.Path.cwd'
)
p
=
mocker
.
patch
(
'poetry.utils._compat.Path.cwd'
)
p
.
return_value
=
Path
(
__file__
)
p
.
return_value
=
Path
(
__file__
)
...
@@ -57,10 +59,12 @@ pytest = "^3.5"
...
@@ -57,10 +59,12 @@ pytest = "^3.5"
assert
expected
in
output
assert
expected
in
output
def
test_interactive_with_dependencies
(
app
,
repo
,
mocker
):
def
test_interactive_with_dependencies
(
app
,
repo
,
mocker
,
poetry
):
repo
.
add_package
(
get_package
(
'pendulum'
,
'2.0.0'
))
repo
.
add_package
(
get_package
(
'pendulum'
,
'2.0.0'
))
command
=
app
.
find
(
'init'
)
command
=
app
.
find
(
'init'
)
command
.
_pool
=
poetry
.
pool
mocker
.
patch
(
'poetry.utils._compat.Path.open'
)
mocker
.
patch
(
'poetry.utils._compat.Path.open'
)
p
=
mocker
.
patch
(
'poetry.utils._compat.Path.cwd'
)
p
=
mocker
.
patch
(
'poetry.utils._compat.Path.cwd'
)
p
.
return_value
=
Path
(
__file__
)
.
parent
p
.
return_value
=
Path
(
__file__
)
.
parent
...
@@ -100,6 +104,4 @@ pendulum = "^2.0"
...
@@ -100,6 +104,4 @@ pendulum = "^2.0"
pytest = "^3.5"
pytest = "^3.5"
"""
"""
print
(
output
)
assert
expected
in
output
assert
expected
in
output
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