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
21abbfc4
Commit
21abbfc4
authored
Oct 20, 2020
by
Arun Babu Neelicattu
Committed by
Steph Samson
Nov 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: ensure mock env uses accessible paths
parent
4a14ebae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
tests/console/conftest.py
+4
-2
tests/installation/test_executor.py
+13
-12
No files found.
tests/console/conftest.py
View file @
21abbfc4
...
@@ -22,8 +22,10 @@ def installer():
...
@@ -22,8 +22,10 @@ def installer():
@pytest.fixture
@pytest.fixture
def
env
():
def
env
(
tmp_dir
):
return
MockEnv
(
path
=
Path
(
"/prefix"
),
base
=
Path
(
"/base/prefix"
),
is_venv
=
True
)
path
=
Path
(
tmp_dir
)
/
".venv"
path
.
mkdir
(
parents
=
True
)
return
MockEnv
(
path
=
path
,
is_venv
=
True
)
@pytest.fixture
(
autouse
=
True
)
@pytest.fixture
(
autouse
=
True
)
...
...
tests/installation/test_executor.py
View file @
21abbfc4
...
@@ -22,6 +22,13 @@ from poetry.utils.env import MockEnv
...
@@ -22,6 +22,13 @@ from poetry.utils.env import MockEnv
from
tests.repositories.test_pypi_repository
import
MockRepository
from
tests.repositories.test_pypi_repository
import
MockRepository
@pytest.fixture
def
env
(
tmp_dir
):
path
=
Path
(
tmp_dir
)
/
".venv"
path
.
mkdir
(
parents
=
True
)
return
MockEnv
(
path
=
path
,
is_venv
=
True
)
@pytest.fixture
()
@pytest.fixture
()
def
io
():
def
io
():
io
=
BufferedIO
()
io
=
BufferedIO
()
...
@@ -57,12 +64,11 @@ def mock_file_downloads(http):
...
@@ -57,12 +64,11 @@ def mock_file_downloads(http):
def
test_execute_executes_a_batch_of_operations
(
def
test_execute_executes_a_batch_of_operations
(
config
,
pool
,
io
,
tmp_dir
,
mock_file_downloads
config
,
pool
,
io
,
tmp_dir
,
mock_file_downloads
,
env
):
):
config
=
Config
()
config
=
Config
()
config
.
merge
({
"cache-dir"
:
tmp_dir
})
config
.
merge
({
"cache-dir"
:
tmp_dir
})
env
=
MockEnv
(
path
=
Path
(
tmp_dir
))
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
file_package
=
Package
(
file_package
=
Package
(
...
@@ -127,12 +133,11 @@ Package operations: 4 installs, 1 update, 1 removal
...
@@ -127,12 +133,11 @@ Package operations: 4 installs, 1 update, 1 removal
def
test_execute_shows_skipped_operations_if_verbose
(
def
test_execute_shows_skipped_operations_if_verbose
(
config
,
pool
,
io
,
config_cache_dir
config
,
pool
,
io
,
config_cache_dir
,
env
):
):
config
=
Config
()
config
=
Config
()
config
.
merge
({
"cache-dir"
:
config_cache_dir
.
as_posix
()})
config
.
merge
({
"cache-dir"
:
config_cache_dir
.
as_posix
()})
env
=
MockEnv
()
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
.
verbose
()
executor
.
verbose
()
...
@@ -152,8 +157,7 @@ Package operations: 0 installs, 0 updates, 0 removals, 1 skipped
...
@@ -152,8 +157,7 @@ Package operations: 0 installs, 0 updates, 0 removals, 1 skipped
@pytest.mark.skipif
(
@pytest.mark.skipif
(
not
PY36
,
reason
=
"Improved error rendering is only available on Python >=3.6"
not
PY36
,
reason
=
"Improved error rendering is only available on Python >=3.6"
)
)
def
test_execute_should_show_errors
(
config
,
mocker
,
io
):
def
test_execute_should_show_errors
(
config
,
mocker
,
io
,
env
):
env
=
MockEnv
()
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
.
verbose
()
executor
.
verbose
()
...
@@ -175,9 +179,8 @@ Package operations: 1 install, 0 updates, 0 removals
...
@@ -175,9 +179,8 @@ Package operations: 1 install, 0 updates, 0 removals
def
test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_interrupt
(
def
test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_interrupt
(
config
,
mocker
,
io
config
,
mocker
,
io
,
env
):
):
env
=
MockEnv
()
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
.
verbose
()
executor
.
verbose
()
...
@@ -196,8 +199,7 @@ Package operations: 1 install, 0 updates, 0 removals
...
@@ -196,8 +199,7 @@ Package operations: 1 install, 0 updates, 0 removals
assert
expected
==
io
.
fetch_output
()
assert
expected
==
io
.
fetch_output
()
def
test_execute_should_gracefully_handle_io_error
(
config
,
mocker
,
io
):
def
test_execute_should_gracefully_handle_io_error
(
config
,
mocker
,
io
,
env
):
env
=
MockEnv
()
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
.
verbose
()
executor
.
verbose
()
...
@@ -223,7 +225,7 @@ Package operations: 1 install, 0 updates, 0 removals
...
@@ -223,7 +225,7 @@ Package operations: 1 install, 0 updates, 0 removals
def
test_executor_should_delete_incomplete_downloads
(
def
test_executor_should_delete_incomplete_downloads
(
config
,
io
,
tmp_dir
,
mocker
,
pool
,
mock_file_downloads
config
,
io
,
tmp_dir
,
mocker
,
pool
,
mock_file_downloads
,
env
):
):
fixture
=
Path
(
__file__
)
.
parent
.
parent
.
joinpath
(
fixture
=
Path
(
__file__
)
.
parent
.
parent
.
joinpath
(
"fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl"
"fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl"
...
@@ -246,7 +248,6 @@ def test_executor_should_delete_incomplete_downloads(
...
@@ -246,7 +248,6 @@ def test_executor_should_delete_incomplete_downloads(
config
=
Config
()
config
=
Config
()
config
.
merge
({
"cache-dir"
:
tmp_dir
})
config
.
merge
({
"cache-dir"
:
tmp_dir
})
env
=
MockEnv
(
path
=
Path
(
tmp_dir
))
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
with
pytest
.
raises
(
Exception
,
match
=
"Download error"
):
with
pytest
.
raises
(
Exception
,
match
=
"Download error"
):
...
...
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