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
99f106c5
Unverified
Commit
99f106c5
authored
Apr 16, 2023
by
David Hotham
Committed by
GitHub
Apr 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some unit test typechecking (#7802)
parent
3855bc58
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
286 additions
and
244 deletions
+286
-244
pyproject.toml
+9
-0
tests/config/test_config.py
+6
-5
tests/console/commands/cache/test_list.py
+2
-2
tests/console/commands/debug/test_resolve.py
+5
-3
tests/console/commands/env/test_list.py
+7
-5
tests/console/commands/env/test_remove.py
+5
-5
tests/console/commands/self/test_add_plugins.py
+8
-8
tests/console/commands/self/test_remove_plugins.py
+2
-2
tests/console/commands/self/test_show_plugins.py
+3
-3
tests/console/commands/test_about.py
+1
-1
tests/console/commands/test_add.py
+0
-0
tests/console/commands/test_config.py
+13
-11
tests/console/commands/test_init.py
+32
-28
tests/console/commands/test_install.py
+24
-16
tests/console/commands/test_lock.py
+6
-6
tests/console/commands/test_new.py
+3
-3
tests/console/commands/test_publish.py
+10
-6
tests/console/commands/test_remove.py
+6
-6
tests/console/commands/test_run.py
+4
-4
tests/console/commands/test_shell.py
+3
-3
tests/console/commands/test_update.py
+1
-1
tests/console/commands/test_version.py
+6
-6
tests/console/test_application.py
+5
-5
tests/installation/test_chef.py
+2
-2
tests/installation/test_executor.py
+26
-24
tests/installation/test_installer.py
+0
-0
tests/integration/test_utils_vcs_git.py
+4
-4
tests/plugins/test_plugin_manager.py
+7
-5
tests/puzzle/test_provider.py
+2
-1
tests/puzzle/test_solver.py
+1
-1
tests/repositories/test_installed_repository.py
+21
-19
tests/utils/test_authenticator.py
+39
-39
tests/utils/test_password_manager.py
+23
-20
No files found.
pyproject.toml
View file @
99f106c5
...
@@ -160,6 +160,11 @@ enable_error_code = [
...
@@ -160,6 +160,11 @@ enable_error_code = [
"redundant-expr"
,
"redundant-expr"
,
"truthy-bool"
,
"truthy-bool"
,
]
]
exclude
=
[
"tests/fixtures"
,
"tests/masonry/builders/fixtures"
,
"tests/utils/fixtures"
]
# use of importlib-metadata backport at python3.7 makes it impossible to
# use of importlib-metadata backport at python3.7 makes it impossible to
# satisfy mypy without some ignores: but we get a different set of ignores at
# satisfy mypy without some ignores: but we get a different set of ignores at
...
@@ -178,6 +183,10 @@ warn_unused_ignores = false
...
@@ -178,6 +183,10 @@ warn_unused_ignores = false
[[tool.mypy.overrides]]
[[tool.mypy.overrides]]
module
=
[
module
=
[
'cachecontrol.*'
,
'cachecontrol.*'
,
'cachy.*'
,
'deepdiff.*'
,
'httpretty.*'
,
'keyring.*'
,
'lockfile.*'
,
'lockfile.*'
,
'pexpect.*'
,
'pexpect.*'
,
'requests_toolbelt.*'
,
'requests_toolbelt.*'
,
...
...
tests/config/test_config.py
View file @
99f106c5
...
@@ -5,6 +5,7 @@ import re
...
@@ -5,6 +5,7 @@ import re
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
import
pytest
import
pytest
...
@@ -19,7 +20,7 @@ if TYPE_CHECKING:
...
@@ -19,7 +20,7 @@ if TYPE_CHECKING:
from
collections.abc
import
Iterator
from
collections.abc
import
Iterator
def
get_options_based_on_normalizer
(
normalizer
:
Callable
)
->
str
:
def
get_options_based_on_normalizer
(
normalizer
:
Callable
[[
str
],
Any
]
)
->
str
:
flattened_config
=
flatten_dict
(
obj
=
Config
.
default_config
,
delimiter
=
"."
)
flattened_config
=
flatten_dict
(
obj
=
Config
.
default_config
,
delimiter
=
"."
)
for
k
in
flattened_config
:
for
k
in
flattened_config
:
...
@@ -30,13 +31,13 @@ def get_options_based_on_normalizer(normalizer: Callable) -> str:
...
@@ -30,13 +31,13 @@ def get_options_based_on_normalizer(normalizer: Callable) -> str:
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
(
"name"
,
"value"
),
[(
"installer.parallel"
,
True
),
(
"virtualenvs.create"
,
True
)]
(
"name"
,
"value"
),
[(
"installer.parallel"
,
True
),
(
"virtualenvs.create"
,
True
)]
)
)
def
test_config_get_default_value
(
config
:
Config
,
name
:
str
,
value
:
bool
):
def
test_config_get_default_value
(
config
:
Config
,
name
:
str
,
value
:
bool
)
->
None
:
assert
config
.
get
(
name
)
is
value
assert
config
.
get
(
name
)
is
value
def
test_config_get_processes_depended_on_values
(
def
test_config_get_processes_depended_on_values
(
config
:
Config
,
config_cache_dir
:
Path
config
:
Config
,
config_cache_dir
:
Path
):
)
->
None
:
assert
str
(
config_cache_dir
/
"virtualenvs"
)
==
config
.
get
(
"virtualenvs.path"
)
assert
str
(
config_cache_dir
/
"virtualenvs"
)
==
config
.
get
(
"virtualenvs.path"
)
...
@@ -62,7 +63,7 @@ def test_config_get_from_environment_variable(
...
@@ -62,7 +63,7 @@ def test_config_get_from_environment_variable(
env_var
:
str
,
env_var
:
str
,
env_value
:
str
,
env_value
:
str
,
value
:
bool
,
value
:
bool
,
):
)
->
None
:
os
.
environ
[
env_var
]
=
env_value
os
.
environ
[
env_var
]
=
env_value
assert
config
.
get
(
name
)
is
value
assert
config
.
get
(
name
)
is
value
...
@@ -73,6 +74,6 @@ def test_config_get_from_environment_variable(
...
@@ -73,6 +74,6 @@ def test_config_get_from_environment_variable(
)
)
def
test_config_expands_tilde_for_virtualenvs_path
(
def
test_config_expands_tilde_for_virtualenvs_path
(
config
:
Config
,
path_config
:
str
,
expected
:
Path
config
:
Config
,
path_config
:
str
,
expected
:
Path
):
)
->
None
:
config
.
merge
({
"virtualenvs"
:
{
"path"
:
path_config
}})
config
.
merge
({
"virtualenvs"
:
{
"path"
:
path_config
}})
assert
config
.
virtualenvs_path
==
expected
assert
config
.
virtualenvs_path
==
expected
tests/console/commands/cache/test_list.py
View file @
99f106c5
...
@@ -20,7 +20,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
...
@@ -20,7 +20,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
def
test_cache_list
(
def
test_cache_list
(
tester
:
CommandTester
,
mock_caches
:
None
,
repository_one
:
str
,
repository_two
:
str
tester
:
CommandTester
,
mock_caches
:
None
,
repository_one
:
str
,
repository_two
:
str
):
)
->
None
:
tester
.
execute
()
tester
.
execute
()
expected
=
f
"""
\
expected
=
f
"""
\
...
@@ -31,7 +31,7 @@ def test_cache_list(
...
@@ -31,7 +31,7 @@ def test_cache_list(
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
def
test_cache_list_empty
(
tester
:
CommandTester
,
repository_cache_dir
:
Path
):
def
test_cache_list_empty
(
tester
:
CommandTester
,
repository_cache_dir
:
Path
)
->
None
:
tester
.
execute
()
tester
.
execute
()
expected
=
"""
\
expected
=
"""
\
...
...
tests/console/commands/debug/test_resolve.py
View file @
99f106c5
...
@@ -33,7 +33,7 @@ def __add_packages(repo: TestRepository) -> None:
...
@@ -33,7 +33,7 @@ def __add_packages(repo: TestRepository) -> None:
repo
.
add_package
(
get_package
(
"cleo"
,
"0.6.5"
))
repo
.
add_package
(
get_package
(
"cleo"
,
"0.6.5"
))
def
test_debug_resolve_gives_resolution_results
(
tester
:
CommandTester
):
def
test_debug_resolve_gives_resolution_results
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
(
"cachy"
)
tester
.
execute
(
"cachy"
)
expected
=
"""
\
expected
=
"""
\
...
@@ -48,7 +48,9 @@ cachy 0.2.0
...
@@ -48,7 +48,9 @@ cachy 0.2.0
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
def
test_debug_resolve_tree_option_gives_the_dependency_tree
(
tester
:
CommandTester
):
def
test_debug_resolve_tree_option_gives_the_dependency_tree
(
tester
:
CommandTester
,
)
->
None
:
tester
.
execute
(
"cachy --tree"
)
tester
.
execute
(
"cachy --tree"
)
expected
=
"""
\
expected
=
"""
\
...
@@ -63,7 +65,7 @@ cachy 0.2.0
...
@@ -63,7 +65,7 @@ cachy 0.2.0
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
def
test_debug_resolve_git_dependency
(
tester
:
CommandTester
):
def
test_debug_resolve_git_dependency
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
(
"git+https://github.com/demo/demo.git"
)
tester
.
execute
(
"git+https://github.com/demo/demo.git"
)
expected
=
"""
\
expected
=
"""
\
...
...
tests/console/commands/env/test_list.py
View file @
99f106c5
...
@@ -36,7 +36,7 @@ def test_none_activated(
...
@@ -36,7 +36,7 @@ def test_none_activated(
venvs_in_cache_dirs
:
list
[
str
],
venvs_in_cache_dirs
:
list
[
str
],
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
mocker
.
patch
(
"poetry.utils.env.EnvManager.get"
,
return_value
=
env
)
mocker
.
patch
(
"poetry.utils.env.EnvManager.get"
,
return_value
=
env
)
tester
.
execute
()
tester
.
execute
()
expected
=
"
\n
"
.
join
(
venvs_in_cache_dirs
)
expected
=
"
\n
"
.
join
(
venvs_in_cache_dirs
)
...
@@ -48,13 +48,15 @@ def test_activated(
...
@@ -48,13 +48,15 @@ def test_activated(
venvs_in_cache_dirs
:
list
[
str
],
venvs_in_cache_dirs
:
list
[
str
],
venv_cache
:
Path
,
venv_cache
:
Path
,
venv_activate_37
:
None
,
venv_activate_37
:
None
,
):
)
->
None
:
tester
.
execute
()
tester
.
execute
()
expected
=
"
\n
"
.
join
(
venvs_in_cache_dirs
)
.
replace
(
"py3.7"
,
"py3.7 (Activated)"
)
expected
=
"
\n
"
.
join
(
venvs_in_cache_dirs
)
.
replace
(
"py3.7"
,
"py3.7 (Activated)"
)
assert
tester
.
io
.
fetch_output
()
.
strip
()
==
expected
assert
tester
.
io
.
fetch_output
()
.
strip
()
==
expected
def
test_in_project_venv
(
tester
:
CommandTester
,
venvs_in_project_dir
:
list
[
str
]):
def
test_in_project_venv
(
tester
:
CommandTester
,
venvs_in_project_dir
:
list
[
str
]
)
->
None
:
tester
.
execute
()
tester
.
execute
()
expected
=
".venv (Activated)
\n
"
expected
=
".venv (Activated)
\n
"
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
...
@@ -62,7 +64,7 @@ def test_in_project_venv(tester: CommandTester, venvs_in_project_dir: list[str])
...
@@ -62,7 +64,7 @@ def test_in_project_venv(tester: CommandTester, venvs_in_project_dir: list[str])
def
test_in_project_venv_no_explicit_config
(
def
test_in_project_venv_no_explicit_config
(
tester
:
CommandTester
,
venvs_in_project_dir_none
:
list
[
str
]
tester
:
CommandTester
,
venvs_in_project_dir_none
:
list
[
str
]
):
)
->
None
:
tester
.
execute
()
tester
.
execute
()
expected
=
".venv (Activated)
\n
"
expected
=
".venv (Activated)
\n
"
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
...
@@ -70,7 +72,7 @@ def test_in_project_venv_no_explicit_config(
...
@@ -70,7 +72,7 @@ def test_in_project_venv_no_explicit_config(
def
test_in_project_venv_is_false
(
def
test_in_project_venv_is_false
(
tester
:
CommandTester
,
venvs_in_project_dir_false
:
list
[
str
]
tester
:
CommandTester
,
venvs_in_project_dir_false
:
list
[
str
]
):
)
->
None
:
tester
.
execute
()
tester
.
execute
()
expected
=
""
expected
=
""
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
tests/console/commands/env/test_remove.py
View file @
99f106c5
...
@@ -29,7 +29,7 @@ def test_remove_by_python_version(
...
@@ -29,7 +29,7 @@ def test_remove_by_python_version(
venvs_in_cache_dirs
:
list
[
str
],
venvs_in_cache_dirs
:
list
[
str
],
venv_name
:
str
,
venv_name
:
str
,
venv_cache
:
Path
,
venv_cache
:
Path
,
):
)
->
None
:
check_output
=
mocker
.
patch
(
check_output
=
mocker
.
patch
(
"subprocess.check_output"
,
"subprocess.check_output"
,
side_effect
=
check_output_wrapper
(
Version
.
parse
(
"3.6.6"
)),
side_effect
=
check_output_wrapper
(
Version
.
parse
(
"3.6.6"
)),
...
@@ -49,7 +49,7 @@ def test_remove_by_name(
...
@@ -49,7 +49,7 @@ def test_remove_by_name(
venvs_in_cache_dirs
:
list
[
str
],
venvs_in_cache_dirs
:
list
[
str
],
venv_name
:
str
,
venv_name
:
str
,
venv_cache
:
Path
,
venv_cache
:
Path
,
):
)
->
None
:
expected
=
""
expected
=
""
for
name
in
venvs_in_cache_dirs
:
for
name
in
venvs_in_cache_dirs
:
...
@@ -67,7 +67,7 @@ def test_remove_all(
...
@@ -67,7 +67,7 @@ def test_remove_all(
venvs_in_cache_dirs
:
list
[
str
],
venvs_in_cache_dirs
:
list
[
str
],
venv_name
:
str
,
venv_name
:
str
,
venv_cache
:
Path
,
venv_cache
:
Path
,
):
)
->
None
:
expected
=
{
""
}
expected
=
{
""
}
tester
.
execute
(
"--all"
)
tester
.
execute
(
"--all"
)
for
name
in
venvs_in_cache_dirs
:
for
name
in
venvs_in_cache_dirs
:
...
@@ -81,7 +81,7 @@ def test_remove_all_and_version(
...
@@ -81,7 +81,7 @@ def test_remove_all_and_version(
venvs_in_cache_dirs
:
list
[
str
],
venvs_in_cache_dirs
:
list
[
str
],
venv_name
:
str
,
venv_name
:
str
,
venv_cache
:
Path
,
venv_cache
:
Path
,
):
)
->
None
:
expected
=
{
""
}
expected
=
{
""
}
tester
.
execute
(
f
"--all {venvs_in_cache_dirs[0]}"
)
tester
.
execute
(
f
"--all {venvs_in_cache_dirs[0]}"
)
for
name
in
venvs_in_cache_dirs
:
for
name
in
venvs_in_cache_dirs
:
...
@@ -95,7 +95,7 @@ def test_remove_multiple(
...
@@ -95,7 +95,7 @@ def test_remove_multiple(
venvs_in_cache_dirs
:
list
[
str
],
venvs_in_cache_dirs
:
list
[
str
],
venv_name
:
str
,
venv_name
:
str
,
venv_cache
:
Path
,
venv_cache
:
Path
,
):
)
->
None
:
expected
=
{
""
}
expected
=
{
""
}
removed_envs
=
venvs_in_cache_dirs
[
0
:
2
]
removed_envs
=
venvs_in_cache_dirs
[
0
:
2
]
remaining_envs
=
venvs_in_cache_dirs
[
2
:]
remaining_envs
=
venvs_in_cache_dirs
[
2
:]
...
...
tests/console/commands/self/test_add_plugins.py
View file @
99f106c5
...
@@ -38,7 +38,7 @@ def assert_plugin_add_result(
...
@@ -38,7 +38,7 @@ def assert_plugin_add_result(
def
test_add_no_constraint
(
def
test_add_no_constraint
(
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
repo
.
add_package
(
Package
(
"poetry-plugin"
,
"0.1.0"
))
repo
.
add_package
(
Package
(
"poetry-plugin"
,
"0.1.0"
))
tester
.
execute
(
"poetry-plugin"
)
tester
.
execute
(
"poetry-plugin"
)
...
@@ -61,7 +61,7 @@ Writing lock file
...
@@ -61,7 +61,7 @@ Writing lock file
def
test_add_with_constraint
(
def
test_add_with_constraint
(
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
repo
.
add_package
(
Package
(
"poetry-plugin"
,
"0.1.0"
))
repo
.
add_package
(
Package
(
"poetry-plugin"
,
"0.1.0"
))
repo
.
add_package
(
Package
(
"poetry-plugin"
,
"0.2.0"
))
repo
.
add_package
(
Package
(
"poetry-plugin"
,
"0.2.0"
))
...
@@ -84,7 +84,7 @@ Writing lock file
...
@@ -84,7 +84,7 @@ Writing lock file
def
test_add_with_git_constraint
(
def
test_add_with_git_constraint
(
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
repo
.
add_package
(
Package
(
"pendulum"
,
"2.0.5"
))
repo
.
add_package
(
Package
(
"pendulum"
,
"2.0.5"
))
tester
.
execute
(
"git+https://github.com/demo/poetry-plugin.git"
)
tester
.
execute
(
"git+https://github.com/demo/poetry-plugin.git"
)
...
@@ -109,7 +109,7 @@ Writing lock file
...
@@ -109,7 +109,7 @@ Writing lock file
def
test_add_with_git_constraint_with_extras
(
def
test_add_with_git_constraint_with_extras
(
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
repo
.
add_package
(
Package
(
"pendulum"
,
"2.0.5"
))
repo
.
add_package
(
Package
(
"pendulum"
,
"2.0.5"
))
repo
.
add_package
(
Package
(
"tomlkit"
,
"0.7.0"
))
repo
.
add_package
(
Package
(
"tomlkit"
,
"0.7.0"
))
...
@@ -153,7 +153,7 @@ def test_add_with_git_constraint_with_subdirectory(
...
@@ -153,7 +153,7 @@ def test_add_with_git_constraint_with_subdirectory(
rev
:
str
|
None
,
rev
:
str
|
None
,
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
repo
.
add_package
(
Package
(
"pendulum"
,
"2.0.5"
))
repo
.
add_package
(
Package
(
"pendulum"
,
"2.0.5"
))
tester
.
execute
(
url
)
tester
.
execute
(
url
)
...
@@ -189,7 +189,7 @@ def test_add_existing_plugin_warns_about_no_operation(
...
@@ -189,7 +189,7 @@ def test_add_existing_plugin_warns_about_no_operation(
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
installed
:
TestRepository
,
installed
:
TestRepository
,
):
)
->
None
:
pyproject
=
SelfCommand
.
get_default_system_pyproject_file
()
pyproject
=
SelfCommand
.
get_default_system_pyproject_file
()
with
open
(
pyproject
,
"w"
,
encoding
=
"utf-8"
,
newline
=
""
)
as
f
:
with
open
(
pyproject
,
"w"
,
encoding
=
"utf-8"
,
newline
=
""
)
as
f
:
f
.
write
(
f
.
write
(
...
@@ -230,7 +230,7 @@ def test_add_existing_plugin_updates_if_requested(
...
@@ -230,7 +230,7 @@ def test_add_existing_plugin_updates_if_requested(
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
installed
:
TestRepository
,
installed
:
TestRepository
,
):
)
->
None
:
pyproject
=
SelfCommand
.
get_default_system_pyproject_file
()
pyproject
=
SelfCommand
.
get_default_system_pyproject_file
()
with
open
(
pyproject
,
"w"
,
encoding
=
"utf-8"
,
newline
=
""
)
as
f
:
with
open
(
pyproject
,
"w"
,
encoding
=
"utf-8"
,
newline
=
""
)
as
f
:
f
.
write
(
f
.
write
(
...
@@ -276,7 +276,7 @@ def test_adding_a_plugin_can_update_poetry_dependencies_if_needed(
...
@@ -276,7 +276,7 @@ def test_adding_a_plugin_can_update_poetry_dependencies_if_needed(
tester
:
CommandTester
,
tester
:
CommandTester
,
repo
:
TestRepository
,
repo
:
TestRepository
,
installed
:
TestRepository
,
installed
:
TestRepository
,
):
)
->
None
:
poetry_package
=
Package
(
"poetry"
,
"1.2.0"
)
poetry_package
=
Package
(
"poetry"
,
"1.2.0"
)
poetry_package
.
add_dependency
(
Factory
.
create_dependency
(
"tomlkit"
,
"^0.7.0"
))
poetry_package
.
add_dependency
(
Factory
.
create_dependency
(
"tomlkit"
,
"^0.7.0"
))
...
...
tests/console/commands/self/test_remove_plugins.py
View file @
99f106c5
...
@@ -66,7 +66,7 @@ def install_plugin(installed: Repository) -> None:
...
@@ -66,7 +66,7 @@ def install_plugin(installed: Repository) -> None:
installed
.
add_package
(
plugin
)
installed
.
add_package
(
plugin
)
def
test_remove_installed_package
(
tester
:
CommandTester
):
def
test_remove_installed_package
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
(
"poetry-plugin"
)
tester
.
execute
(
"poetry-plugin"
)
expected
=
"""
\
expected
=
"""
\
...
@@ -87,7 +87,7 @@ Writing lock file
...
@@ -87,7 +87,7 @@ Writing lock file
assert
not
dependencies
assert
not
dependencies
def
test_remove_installed_package_dry_run
(
tester
:
CommandTester
):
def
test_remove_installed_package_dry_run
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
(
"poetry-plugin --dry-run"
)
tester
.
execute
(
"poetry-plugin --dry-run"
)
expected
=
f
"""
\
expected
=
f
"""
\
...
...
tests/console/commands/self/test_show_plugins.py
View file @
99f106c5
...
@@ -153,7 +153,7 @@ def mock_metadata_entry_points(
...
@@ -153,7 +153,7 @@ def mock_metadata_entry_points(
def
test_show_displays_installed_plugins
(
def
test_show_displays_installed_plugins
(
app
:
PoetryTestApplication
,
app
:
PoetryTestApplication
,
tester
:
CommandTester
,
tester
:
CommandTester
,
):
)
->
None
:
tester
.
execute
(
""
)
tester
.
execute
(
""
)
expected
=
"""
expected
=
"""
...
@@ -179,7 +179,7 @@ def test_show_displays_installed_plugins(
...
@@ -179,7 +179,7 @@ def test_show_displays_installed_plugins(
def
test_show_displays_installed_plugins_with_multiple_plugins
(
def
test_show_displays_installed_plugins_with_multiple_plugins
(
app
:
PoetryTestApplication
,
app
:
PoetryTestApplication
,
tester
:
CommandTester
,
tester
:
CommandTester
,
):
)
->
None
:
tester
.
execute
(
""
)
tester
.
execute
(
""
)
expected
=
"""
expected
=
"""
...
@@ -205,7 +205,7 @@ def test_show_displays_installed_plugins_with_multiple_plugins(
...
@@ -205,7 +205,7 @@ def test_show_displays_installed_plugins_with_multiple_plugins(
def
test_show_displays_installed_plugins_with_dependencies
(
def
test_show_displays_installed_plugins_with_dependencies
(
app
:
PoetryTestApplication
,
app
:
PoetryTestApplication
,
tester
:
CommandTester
,
tester
:
CommandTester
,
):
)
->
None
:
tester
.
execute
(
""
)
tester
.
execute
(
""
)
expected
=
"""
expected
=
"""
...
...
tests/console/commands/test_about.py
View file @
99f106c5
...
@@ -16,7 +16,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
...
@@ -16,7 +16,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
return
command_tester_factory
(
"about"
)
return
command_tester_factory
(
"about"
)
def
test_about
(
tester
:
CommandTester
):
def
test_about
(
tester
:
CommandTester
)
->
None
:
from
poetry.utils._compat
import
metadata
from
poetry.utils._compat
import
metadata
tester
.
execute
()
tester
.
execute
()
...
...
tests/console/commands/test_add.py
View file @
99f106c5
This diff is collapsed.
Click to expand it.
tests/console/commands/test_config.py
View file @
99f106c5
...
@@ -34,7 +34,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
...
@@ -34,7 +34,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
def
test_show_config_with_local_config_file_empty
(
def
test_show_config_with_local_config_file_empty
(
tester
:
CommandTester
,
mocker
:
MockerFixture
tester
:
CommandTester
,
mocker
:
MockerFixture
):
)
->
None
:
mocker
.
patch
(
mocker
.
patch
(
"poetry.factory.Factory.create_poetry"
,
"poetry.factory.Factory.create_poetry"
,
side_effect
=
PyProjectException
(
"[tool.poetry] section not found"
),
side_effect
=
PyProjectException
(
"[tool.poetry] section not found"
),
...
@@ -46,7 +46,7 @@ def test_show_config_with_local_config_file_empty(
...
@@ -46,7 +46,7 @@ def test_show_config_with_local_config_file_empty(
def
test_list_displays_default_value_if_not_set
(
def
test_list_displays_default_value_if_not_set
(
tester
:
CommandTester
,
config
:
Config
,
config_cache_dir
:
Path
tester
:
CommandTester
,
config
:
Config
,
config_cache_dir
:
Path
):
)
->
None
:
tester
.
execute
(
"--list"
)
tester
.
execute
(
"--list"
)
cache_dir
=
json
.
dumps
(
str
(
config_cache_dir
))
cache_dir
=
json
.
dumps
(
str
(
config_cache_dir
))
...
@@ -74,7 +74,7 @@ virtualenvs.prompt = "{{project_name}}-py{{python_version}}"
...
@@ -74,7 +74,7 @@ virtualenvs.prompt = "{{project_name}}-py{{python_version}}"
def
test_list_displays_set_get_setting
(
def
test_list_displays_set_get_setting
(
tester
:
CommandTester
,
config
:
Config
,
config_cache_dir
:
Path
tester
:
CommandTester
,
config
:
Config
,
config_cache_dir
:
Path
):
)
->
None
:
tester
.
execute
(
"virtualenvs.create false"
)
tester
.
execute
(
"virtualenvs.create false"
)
tester
.
execute
(
"--list"
)
tester
.
execute
(
"--list"
)
...
@@ -103,7 +103,7 @@ virtualenvs.prompt = "{{project_name}}-py{{python_version}}"
...
@@ -103,7 +103,7 @@ virtualenvs.prompt = "{{project_name}}-py{{python_version}}"
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
def
test_display_single_setting
(
tester
:
CommandTester
,
config
:
Config
):
def
test_display_single_setting
(
tester
:
CommandTester
,
config
:
Config
)
->
None
:
tester
.
execute
(
"virtualenvs.create"
)
tester
.
execute
(
"virtualenvs.create"
)
expected
=
"""true
expected
=
"""true
...
@@ -114,7 +114,7 @@ def test_display_single_setting(tester: CommandTester, config: Config):
...
@@ -114,7 +114,7 @@ def test_display_single_setting(tester: CommandTester, config: Config):
def
test_display_single_local_setting
(
def
test_display_single_local_setting
(
command_tester_factory
:
CommandTesterFactory
,
fixture_dir
:
FixtureDirGetter
command_tester_factory
:
CommandTesterFactory
,
fixture_dir
:
FixtureDirGetter
):
)
->
None
:
tester
=
command_tester_factory
(
tester
=
command_tester_factory
(
"config"
,
poetry
=
Factory
()
.
create_poetry
(
fixture_dir
(
"with_local_config"
))
"config"
,
poetry
=
Factory
()
.
create_poetry
(
fixture_dir
(
"with_local_config"
))
)
)
...
@@ -128,7 +128,7 @@ def test_display_single_local_setting(
...
@@ -128,7 +128,7 @@ def test_display_single_local_setting(
def
test_list_displays_set_get_local_setting
(
def
test_list_displays_set_get_local_setting
(
tester
:
CommandTester
,
config
:
Config
,
config_cache_dir
:
Path
tester
:
CommandTester
,
config
:
Config
,
config_cache_dir
:
Path
):
)
->
None
:
tester
.
execute
(
"virtualenvs.create false --local"
)
tester
.
execute
(
"virtualenvs.create false --local"
)
tester
.
execute
(
"--list"
)
tester
.
execute
(
"--list"
)
...
@@ -163,7 +163,7 @@ def test_list_must_not_display_sources_from_pyproject_toml(
...
@@ -163,7 +163,7 @@ def test_list_must_not_display_sources_from_pyproject_toml(
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
config
:
Config
,
config
:
Config
,
config_cache_dir
:
Path
,
config_cache_dir
:
Path
,
):
)
->
None
:
source
=
fixture_dir
(
"with_non_default_source_implicit"
)
source
=
fixture_dir
(
"with_non_default_source_implicit"
)
pyproject_content
=
(
source
/
"pyproject.toml"
)
.
read_text
(
encoding
=
"utf-8"
)
pyproject_content
=
(
source
/
"pyproject.toml"
)
.
read_text
(
encoding
=
"utf-8"
)
poetry
=
project_factory
(
"foo"
,
pyproject_content
=
pyproject_content
)
poetry
=
project_factory
(
"foo"
,
pyproject_content
=
pyproject_content
)
...
@@ -195,7 +195,9 @@ virtualenvs.prompt = "{{project_name}}-py{{python_version}}"
...
@@ -195,7 +195,9 @@ virtualenvs.prompt = "{{project_name}}-py{{python_version}}"
assert
tester
.
io
.
fetch_output
()
==
expected
assert
tester
.
io
.
fetch_output
()
==
expected
def
test_set_pypi_token
(
tester
:
CommandTester
,
auth_config_source
:
DictConfigSource
):
def
test_set_pypi_token
(
tester
:
CommandTester
,
auth_config_source
:
DictConfigSource
)
->
None
:
tester
.
execute
(
"pypi-token.pypi mytoken"
)
tester
.
execute
(
"pypi-token.pypi mytoken"
)
tester
.
execute
(
"--list"
)
tester
.
execute
(
"--list"
)
...
@@ -206,7 +208,7 @@ def test_set_client_cert(
...
@@ -206,7 +208,7 @@ def test_set_client_cert(
tester
:
CommandTester
,
tester
:
CommandTester
,
auth_config_source
:
DictConfigSource
,
auth_config_source
:
DictConfigSource
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
mocker
.
spy
(
ConfigSource
,
"__init__"
)
mocker
.
spy
(
ConfigSource
,
"__init__"
)
tester
.
execute
(
"certificates.foo.client-cert path/to/cert.pem"
)
tester
.
execute
(
"certificates.foo.client-cert path/to/cert.pem"
)
...
@@ -231,7 +233,7 @@ def test_set_cert(
...
@@ -231,7 +233,7 @@ def test_set_cert(
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
value
:
str
,
value
:
str
,
result
:
str
|
bool
,
result
:
str
|
bool
,
):
)
->
None
:
mocker
.
spy
(
ConfigSource
,
"__init__"
)
mocker
.
spy
(
ConfigSource
,
"__init__"
)
tester
.
execute
(
f
"certificates.foo.cert {value}"
)
tester
.
execute
(
f
"certificates.foo.cert {value}"
)
...
@@ -241,7 +243,7 @@ def test_set_cert(
...
@@ -241,7 +243,7 @@ def test_set_cert(
def
test_config_installer_parallel
(
def
test_config_installer_parallel
(
tester
:
CommandTester
,
command_tester_factory
:
CommandTesterFactory
tester
:
CommandTester
,
command_tester_factory
:
CommandTesterFactory
):
)
->
None
:
tester
.
execute
(
"--local installer.parallel"
)
tester
.
execute
(
"--local installer.parallel"
)
assert
tester
.
io
.
fetch_output
()
.
strip
()
==
"true"
assert
tester
.
io
.
fetch_output
()
.
strip
()
==
"true"
...
...
tests/console/commands/test_init.py
View file @
99f106c5
...
@@ -95,7 +95,7 @@ python = "~2.7 || ^3.6"
...
@@ -95,7 +95,7 @@ python = "~2.7 || ^3.6"
def
test_basic_interactive
(
def
test_basic_interactive
(
tester
:
CommandTester
,
init_basic_inputs
:
str
,
init_basic_toml
:
str
tester
:
CommandTester
,
init_basic_inputs
:
str
,
init_basic_toml
:
str
):
)
->
None
:
tester
.
execute
(
inputs
=
init_basic_inputs
)
tester
.
execute
(
inputs
=
init_basic_inputs
)
assert
init_basic_toml
in
tester
.
io
.
fetch_output
()
assert
init_basic_toml
in
tester
.
io
.
fetch_output
()
...
@@ -106,7 +106,7 @@ def test_noninteractive(
...
@@ -106,7 +106,7 @@ def test_noninteractive(
poetry
:
Poetry
,
poetry
:
Poetry
,
repo
:
TestRepository
,
repo
:
TestRepository
,
tmp_path
:
Path
,
tmp_path
:
Path
,
):
)
->
None
:
command
=
app
.
find
(
"init"
)
command
=
app
.
find
(
"init"
)
command
.
_pool
=
poetry
.
pool
command
.
_pool
=
poetry
.
pool
...
@@ -128,7 +128,9 @@ def test_noninteractive(
...
@@ -128,7 +128,9 @@ def test_noninteractive(
assert
'pytest = "^3.6.0"'
in
toml_content
assert
'pytest = "^3.6.0"'
in
toml_content
def
test_interactive_with_dependencies
(
tester
:
CommandTester
,
repo
:
TestRepository
):
def
test_interactive_with_dependencies
(
tester
:
CommandTester
,
repo
:
TestRepository
)
->
None
:
repo
.
add_package
(
get_package
(
"django-pendulum"
,
"0.1.6-pre4"
))
repo
.
add_package
(
get_package
(
"django-pendulum"
,
"0.1.6-pre4"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -183,7 +185,7 @@ pytest = "^3.6.0"
...
@@ -183,7 +185,7 @@ pytest = "^3.6.0"
# Regression test for https://github.com/python-poetry/poetry/issues/2355
# Regression test for https://github.com/python-poetry/poetry/issues/2355
def
test_interactive_with_dependencies_and_no_selection
(
def
test_interactive_with_dependencies_and_no_selection
(
tester
:
CommandTester
,
repo
:
TestRepository
tester
:
CommandTester
,
repo
:
TestRepository
):
)
->
None
:
repo
.
add_package
(
get_package
(
"django-pendulum"
,
"0.1.6-pre4"
))
repo
.
add_package
(
get_package
(
"django-pendulum"
,
"0.1.6-pre4"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -224,7 +226,7 @@ python = "~2.7 || ^3.6"
...
@@ -224,7 +226,7 @@ python = "~2.7 || ^3.6"
assert
expected
in
tester
.
io
.
fetch_output
()
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_empty_license
(
tester
:
CommandTester
):
def
test_empty_license
(
tester
:
CommandTester
)
->
None
:
inputs
=
[
inputs
=
[
"my-package"
,
# Package name
"my-package"
,
# Package name
"1.2.3"
,
# Version
"1.2.3"
,
# Version
...
@@ -254,7 +256,9 @@ python = "^{python}"
...
@@ -254,7 +256,9 @@ python = "^{python}"
assert
expected
in
tester
.
io
.
fetch_output
()
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_interactive_with_git_dependencies
(
tester
:
CommandTester
,
repo
:
TestRepository
):
def
test_interactive_with_git_dependencies
(
tester
:
CommandTester
,
repo
:
TestRepository
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -332,7 +336,7 @@ def test_generate_choice_list(
...
@@ -332,7 +336,7 @@ def test_generate_choice_list(
tester
:
CommandTester
,
tester
:
CommandTester
,
package_name
:
str
,
package_name
:
str
,
_generate_choice_list_packages
:
list
[
Package
],
_generate_choice_list_packages
:
list
[
Package
],
):
)
->
None
:
init_command
=
tester
.
command
init_command
=
tester
.
command
packages
=
_generate_choice_list_packages
packages
=
_generate_choice_list_packages
...
@@ -345,7 +349,7 @@ def test_generate_choice_list(
...
@@ -345,7 +349,7 @@ def test_generate_choice_list(
def
test_interactive_with_git_dependencies_with_reference
(
def
test_interactive_with_git_dependencies_with_reference
(
tester
:
CommandTester
,
repo
:
TestRepository
tester
:
CommandTester
,
repo
:
TestRepository
):
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -391,7 +395,7 @@ pytest = "^3.6.0"
...
@@ -391,7 +395,7 @@ pytest = "^3.6.0"
def
test_interactive_with_git_dependencies_and_other_name
(
def
test_interactive_with_git_dependencies_and_other_name
(
tester
:
CommandTester
,
repo
:
TestRepository
tester
:
CommandTester
,
repo
:
TestRepository
):
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -440,7 +444,7 @@ def test_interactive_with_directory_dependency(
...
@@ -440,7 +444,7 @@ def test_interactive_with_directory_dependency(
repo
:
TestRepository
,
repo
:
TestRepository
,
source_dir
:
Path
,
source_dir
:
Path
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -491,7 +495,7 @@ def test_interactive_with_directory_dependency_and_other_name(
...
@@ -491,7 +495,7 @@ def test_interactive_with_directory_dependency_and_other_name(
repo
:
TestRepository
,
repo
:
TestRepository
,
source_dir
:
Path
,
source_dir
:
Path
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -543,7 +547,7 @@ def test_interactive_with_file_dependency(
...
@@ -543,7 +547,7 @@ def test_interactive_with_file_dependency(
repo
:
TestRepository
,
repo
:
TestRepository
,
source_dir
:
Path
,
source_dir
:
Path
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -592,7 +596,7 @@ pytest = "^3.6.0"
...
@@ -592,7 +596,7 @@ pytest = "^3.6.0"
def
test_interactive_with_wrong_dependency_inputs
(
def
test_interactive_with_wrong_dependency_inputs
(
tester
:
CommandTester
,
repo
:
TestRepository
tester
:
CommandTester
,
repo
:
TestRepository
):
)
->
None
:
inputs
=
[
inputs
=
[
"my-package"
,
# Package name
"my-package"
,
# Package name
"1.2.3"
,
# Version
"1.2.3"
,
# Version
...
@@ -636,7 +640,7 @@ pytest = "3.6.0"
...
@@ -636,7 +640,7 @@ pytest = "3.6.0"
assert
expected
in
tester
.
io
.
fetch_output
()
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_python_option
(
tester
:
CommandTester
):
def
test_python_option
(
tester
:
CommandTester
)
->
None
:
inputs
=
[
inputs
=
[
"my-package"
,
# Package name
"my-package"
,
# Package name
"1.2.3"
,
# Version
"1.2.3"
,
# Version
...
@@ -666,7 +670,7 @@ python = "~2.7 || ^3.6"
...
@@ -666,7 +670,7 @@ python = "~2.7 || ^3.6"
assert
expected
in
tester
.
io
.
fetch_output
()
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_predefined_dependency
(
tester
:
CommandTester
,
repo
:
TestRepository
):
def
test_predefined_dependency
(
tester
:
CommandTester
,
repo
:
TestRepository
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
inputs
=
[
inputs
=
[
...
@@ -702,7 +706,7 @@ pendulum = "^2.0.0"
...
@@ -702,7 +706,7 @@ pendulum = "^2.0.0"
def
test_predefined_and_interactive_dependencies
(
def
test_predefined_and_interactive_dependencies
(
tester
:
CommandTester
,
repo
:
TestRepository
tester
:
CommandTester
,
repo
:
TestRepository
):
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pyramid"
,
"1.10"
))
repo
.
add_package
(
get_package
(
"pyramid"
,
"1.10"
))
...
@@ -743,7 +747,7 @@ python = "~2.7 || ^3.6"
...
@@ -743,7 +747,7 @@ python = "~2.7 || ^3.6"
assert
'pyramid = "^1.10"'
in
output
assert
'pyramid = "^1.10"'
in
output
def
test_predefined_dev_dependency
(
tester
:
CommandTester
,
repo
:
TestRepository
):
def
test_predefined_dev_dependency
(
tester
:
CommandTester
,
repo
:
TestRepository
)
->
None
:
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
inputs
=
[
inputs
=
[
...
@@ -782,7 +786,7 @@ pytest = "^3.6.0"
...
@@ -782,7 +786,7 @@ pytest = "^3.6.0"
def
test_predefined_and_interactive_dev_dependencies
(
def
test_predefined_and_interactive_dev_dependencies
(
tester
:
CommandTester
,
repo
:
TestRepository
tester
:
CommandTester
,
repo
:
TestRepository
):
)
->
None
:
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest-requests"
,
"0.2.0"
))
repo
.
add_package
(
get_package
(
"pytest-requests"
,
"0.2.0"
))
...
@@ -828,7 +832,7 @@ pytest-requests = "^0.2.0"
...
@@ -828,7 +832,7 @@ pytest-requests = "^0.2.0"
assert
'pytest = "^3.6.0"'
in
output
assert
'pytest = "^3.6.0"'
in
output
def
test_predefined_all_options
(
tester
:
CommandTester
,
repo
:
TestRepository
):
def
test_predefined_all_options
(
tester
:
CommandTester
,
repo
:
TestRepository
)
->
None
:
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pendulum"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
repo
.
add_package
(
get_package
(
"pytest"
,
"3.6.0"
))
...
@@ -875,7 +879,7 @@ pytest = "^3.6.0"
...
@@ -875,7 +879,7 @@ pytest = "^3.6.0"
assert
expected
in
output
assert
expected
in
output
def
test_add_package_with_extras_and_whitespace
(
tester
:
CommandTester
):
def
test_add_package_with_extras_and_whitespace
(
tester
:
CommandTester
)
->
None
:
result
=
tester
.
command
.
_parse_requirements
([
"databases[postgresql, sqlite]"
])
result
=
tester
.
command
.
_parse_requirements
([
"databases[postgresql, sqlite]"
])
assert
result
[
0
][
"name"
]
==
"databases"
assert
result
[
0
][
"name"
]
==
"databases"
...
@@ -889,7 +893,7 @@ def test_init_existing_pyproject_simple(
...
@@ -889,7 +893,7 @@ def test_init_existing_pyproject_simple(
source_dir
:
Path
,
source_dir
:
Path
,
init_basic_inputs
:
str
,
init_basic_inputs
:
str
,
init_basic_toml
:
str
,
init_basic_toml
:
str
,
):
)
->
None
:
pyproject_file
=
source_dir
/
"pyproject.toml"
pyproject_file
=
source_dir
/
"pyproject.toml"
existing_section
=
"""
existing_section
=
"""
[tool.black]
[tool.black]
...
@@ -907,7 +911,7 @@ def test_init_existing_pyproject_consistent_linesep(
...
@@ -907,7 +911,7 @@ def test_init_existing_pyproject_consistent_linesep(
init_basic_inputs
:
str
,
init_basic_inputs
:
str
,
init_basic_toml
:
str
,
init_basic_toml
:
str
,
linesep
:
str
,
linesep
:
str
,
):
)
->
None
:
pyproject_file
=
source_dir
/
"pyproject.toml"
pyproject_file
=
source_dir
/
"pyproject.toml"
existing_section
=
"""
existing_section
=
"""
[tool.black]
[tool.black]
...
@@ -929,7 +933,7 @@ def test_init_non_interactive_existing_pyproject_add_dependency(
...
@@ -929,7 +933,7 @@ def test_init_non_interactive_existing_pyproject_add_dependency(
source_dir
:
Path
,
source_dir
:
Path
,
init_basic_inputs
:
str
,
init_basic_inputs
:
str
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
pyproject_file
=
source_dir
/
"pyproject.toml"
pyproject_file
=
source_dir
/
"pyproject.toml"
existing_section
=
"""
existing_section
=
"""
[tool.black]
[tool.black]
...
@@ -967,7 +971,7 @@ foo = "^1.19.2"
...
@@ -967,7 +971,7 @@ foo = "^1.19.2"
def
test_init_existing_pyproject_with_build_system_fails
(
def
test_init_existing_pyproject_with_build_system_fails
(
tester
:
CommandTester
,
source_dir
:
Path
,
init_basic_inputs
:
str
tester
:
CommandTester
,
source_dir
:
Path
,
init_basic_inputs
:
str
):
)
->
None
:
pyproject_file
=
source_dir
/
"pyproject.toml"
pyproject_file
=
source_dir
/
"pyproject.toml"
existing_section
=
"""
existing_section
=
"""
[build-system]
[build-system]
...
@@ -997,14 +1001,14 @@ build-backend = "setuptools.build_meta"
...
@@ -997,14 +1001,14 @@ build-backend = "setuptools.build_meta"
" foo 2.0 "
,
" foo 2.0 "
,
],
],
)
)
def
test_
_validate_package_valid
(
name
:
str
|
None
)
:
def
test_
validate_package_valid
(
name
:
str
|
None
)
->
None
:
assert
InitCommand
.
_validate_package
(
name
)
==
name
assert
InitCommand
.
_validate_package
(
name
)
==
name
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"name"
,
[
"foo bar 2.0"
,
" foo bar 2.0 "
,
"foo bar foobar 2.0"
]
"name"
,
[
"foo bar 2.0"
,
" foo bar 2.0 "
,
"foo bar foobar 2.0"
]
)
)
def
test_
_validate_package_invalid
(
name
:
str
)
:
def
test_
validate_package_invalid
(
name
:
str
)
->
None
:
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
):
assert
InitCommand
.
_validate_package
(
name
)
assert
InitCommand
.
_validate_package
(
name
)
...
@@ -1023,7 +1027,7 @@ def test_package_include(
...
@@ -1023,7 +1027,7 @@ def test_package_include(
tester
:
CommandTester
,
tester
:
CommandTester
,
package_name
:
str
,
package_name
:
str
,
include
:
str
|
None
,
include
:
str
|
None
,
):
)
->
None
:
tester
.
execute
(
tester
.
execute
(
inputs
=
"
\n
"
.
join
(
inputs
=
"
\n
"
.
join
(
(
(
...
@@ -1074,7 +1078,7 @@ def test_respect_prefer_active_on_init(
...
@@ -1074,7 +1078,7 @@ def test_respect_prefer_active_on_init(
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
tester
:
CommandTester
,
tester
:
CommandTester
,
source_dir
:
Path
,
source_dir
:
Path
,
):
)
->
None
:
from
poetry.utils.env
import
GET_PYTHON_VERSION_ONELINER
from
poetry.utils.env
import
GET_PYTHON_VERSION_ONELINER
orig_check_output
=
subprocess
.
check_output
orig_check_output
=
subprocess
.
check_output
...
...
tests/console/commands/test_install.py
View file @
99f106c5
...
@@ -119,7 +119,7 @@ def test_group_options_are_passed_to_the_installer(
...
@@ -119,7 +119,7 @@ def test_group_options_are_passed_to_the_installer(
with_root
:
bool
,
with_root
:
bool
,
tester
:
CommandTester
,
tester
:
CommandTester
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
"""
"""
Group options are passed properly to the installer.
Group options are passed properly to the installer.
"""
"""
...
@@ -155,7 +155,7 @@ def test_group_options_are_passed_to_the_installer(
...
@@ -155,7 +155,7 @@ def test_group_options_are_passed_to_the_installer(
def
test_sync_option_is_passed_to_the_installer
(
def
test_sync_option_is_passed_to_the_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
tester
:
CommandTester
,
mocker
:
MockerFixture
):
)
->
None
:
"""
"""
The --sync option is passed properly to the installer.
The --sync option is passed properly to the installer.
"""
"""
...
@@ -169,7 +169,7 @@ def test_sync_option_is_passed_to_the_installer(
...
@@ -169,7 +169,7 @@ def test_sync_option_is_passed_to_the_installer(
@pytest.mark.parametrize
(
"compile"
,
[
False
,
True
])
@pytest.mark.parametrize
(
"compile"
,
[
False
,
True
])
def
test_compile_option_is_passed_to_the_installer
(
def
test_compile_option_is_passed_to_the_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
,
compile
:
bool
tester
:
CommandTester
,
mocker
:
MockerFixture
,
compile
:
bool
):
)
->
None
:
"""
"""
The --compile option is passed properly to the installer.
The --compile option is passed properly to the installer.
"""
"""
...
@@ -187,7 +187,7 @@ def test_compile_option_is_passed_to_the_installer(
...
@@ -187,7 +187,7 @@ def test_compile_option_is_passed_to_the_installer(
@pytest.mark.parametrize
(
"skip_directory_cli_value"
,
[
True
,
False
])
@pytest.mark.parametrize
(
"skip_directory_cli_value"
,
[
True
,
False
])
def
test_no_directory_is_passed_to_installer
(
def
test_no_directory_is_passed_to_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
,
skip_directory_cli_value
:
bool
tester
:
CommandTester
,
mocker
:
MockerFixture
,
skip_directory_cli_value
:
bool
):
)
->
None
:
"""
"""
The --no-directory option is passed to the installer.
The --no-directory option is passed to the installer.
"""
"""
...
@@ -204,7 +204,7 @@ def test_no_directory_is_passed_to_installer(
...
@@ -204,7 +204,7 @@ def test_no_directory_is_passed_to_installer(
def
test_no_all_extras_doesnt_populate_installer
(
def
test_no_all_extras_doesnt_populate_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
tester
:
CommandTester
,
mocker
:
MockerFixture
):
)
->
None
:
"""
"""
Not passing --all-extras means the installer doesn't see any extras.
Not passing --all-extras means the installer doesn't see any extras.
"""
"""
...
@@ -215,7 +215,9 @@ def test_no_all_extras_doesnt_populate_installer(
...
@@ -215,7 +215,9 @@ def test_no_all_extras_doesnt_populate_installer(
assert
not
tester
.
command
.
installer
.
_extras
assert
not
tester
.
command
.
installer
.
_extras
def
test_all_extras_populates_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_all_extras_populates_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
"""
"""
The --all-extras option results in extras passed to the installer.
The --all-extras option results in extras passed to the installer.
"""
"""
...
@@ -229,7 +231,7 @@ def test_all_extras_populates_installer(tester: CommandTester, mocker: MockerFix
...
@@ -229,7 +231,7 @@ def test_all_extras_populates_installer(tester: CommandTester, mocker: MockerFix
def
test_extras_are_parsed_and_populate_installer
(
def
test_extras_are_parsed_and_populate_installer
(
tester
:
CommandTester
,
tester
:
CommandTester
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
tester
.
execute
(
'--extras "first second third"'
)
tester
.
execute
(
'--extras "first second third"'
)
...
@@ -237,7 +239,9 @@ def test_extras_are_parsed_and_populate_installer(
...
@@ -237,7 +239,9 @@ def test_extras_are_parsed_and_populate_installer(
assert
tester
.
command
.
installer
.
_extras
==
[
"first"
,
"second"
,
"third"
]
assert
tester
.
command
.
installer
.
_extras
==
[
"first"
,
"second"
,
"third"
]
def
test_extras_conflicts_all_extras
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_extras_conflicts_all_extras
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
"""
"""
The --extras doesn't make sense with --all-extras.
The --extras doesn't make sense with --all-extras.
"""
"""
...
@@ -266,7 +270,7 @@ def test_only_root_conflicts_with_without_only(
...
@@ -266,7 +270,7 @@ def test_only_root_conflicts_with_without_only(
options
:
str
,
options
:
str
,
tester
:
CommandTester
,
tester
:
CommandTester
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
tester
.
execute
(
f
"{options} --only-root"
)
tester
.
execute
(
f
"{options} --only-root"
)
...
@@ -300,7 +304,7 @@ def test_invalid_groups_with_without_only(
...
@@ -300,7 +304,7 @@ def test_invalid_groups_with_without_only(
options
:
dict
[
str
,
str
],
options
:
dict
[
str
,
str
],
valid_groups
:
set
[
str
],
valid_groups
:
set
[
str
],
should_raise
:
bool
,
should_raise
:
bool
,
):
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
cmd_args
=
" "
.
join
(
f
"{flag} {groups}"
for
(
flag
,
groups
)
in
options
.
items
())
cmd_args
=
" "
.
join
(
f
"{flag} {groups}"
for
(
flag
,
groups
)
in
options
.
items
())
...
@@ -324,7 +328,7 @@ def test_invalid_groups_with_without_only(
...
@@ -324,7 +328,7 @@ def test_invalid_groups_with_without_only(
def
test_remove_untracked_outputs_deprecation_warning
(
def
test_remove_untracked_outputs_deprecation_warning
(
tester
:
CommandTester
,
tester
:
CommandTester
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
tester
.
execute
(
"--remove-untracked"
)
tester
.
execute
(
"--remove-untracked"
)
...
@@ -337,7 +341,9 @@ def test_remove_untracked_outputs_deprecation_warning(
...
@@ -337,7 +341,9 @@ def test_remove_untracked_outputs_deprecation_warning(
)
)
def
test_dry_run_populates_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_dry_run_populates_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
"""
"""
The --dry-run option results in extras passed to the installer.
The --dry-run option results in extras passed to the installer.
"""
"""
...
@@ -349,7 +355,7 @@ def test_dry_run_populates_installer(tester: CommandTester, mocker: MockerFixtur
...
@@ -349,7 +355,7 @@ def test_dry_run_populates_installer(tester: CommandTester, mocker: MockerFixtur
assert
tester
.
command
.
installer
.
_dry_run
is
True
assert
tester
.
command
.
installer
.
_dry_run
is
True
def
test_dry_run_does_not_build
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_dry_run_does_not_build
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocked_editable_builder
=
mocker
.
patch
(
mocked_editable_builder
=
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
"poetry.masonry.builders.editable.EditableBuilder"
...
@@ -360,7 +366,7 @@ def test_dry_run_does_not_build(tester: CommandTester, mocker: MockerFixture):
...
@@ -360,7 +366,7 @@ def test_dry_run_does_not_build(tester: CommandTester, mocker: MockerFixture):
assert
mocked_editable_builder
.
return_value
.
build
.
call_count
==
0
assert
mocked_editable_builder
.
return_value
.
build
.
call_count
==
0
def
test_install_logs_output
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_install_logs_output
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
)
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
)
...
@@ -373,7 +379,9 @@ def test_install_logs_output(tester: CommandTester, mocker: MockerFixture):
...
@@ -373,7 +379,9 @@ def test_install_logs_output(tester: CommandTester, mocker: MockerFixture):
)
)
def
test_install_logs_output_decorated
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_install_logs_output_decorated
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
)
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
)
...
@@ -402,7 +410,7 @@ def test_install_path_dependency_does_not_exist(
...
@@ -402,7 +410,7 @@ def test_install_path_dependency_does_not_exist(
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
project
:
str
,
project
:
str
,
options
:
str
,
options
:
str
,
):
)
->
None
:
poetry
=
_project_factory
(
project
,
project_factory
,
fixture_dir
)
poetry
=
_project_factory
(
project
,
project_factory
,
fixture_dir
)
poetry
.
locker
.
locked
(
True
)
poetry
.
locker
.
locked
(
True
)
tester
=
command_tester_factory
(
"install"
,
poetry
=
poetry
)
tester
=
command_tester_factory
(
"install"
,
poetry
=
poetry
)
...
...
tests/console/commands/test_lock.py
View file @
99f106c5
...
@@ -93,7 +93,7 @@ def test_lock_check_outdated(
...
@@ -93,7 +93,7 @@ def test_lock_check_outdated(
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
poetry_with_outdated_lockfile
:
Poetry
,
poetry_with_outdated_lockfile
:
Poetry
,
http
:
type
[
httpretty
.
httpretty
],
http
:
type
[
httpretty
.
httpretty
],
):
)
->
None
:
http
.
disable
()
http
.
disable
()
locker
=
Locker
(
locker
=
Locker
(
...
@@ -119,7 +119,7 @@ def test_lock_check_up_to_date(
...
@@ -119,7 +119,7 @@ def test_lock_check_up_to_date(
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
poetry_with_up_to_date_lockfile
:
Poetry
,
poetry_with_up_to_date_lockfile
:
Poetry
,
http
:
type
[
httpretty
.
httpretty
],
http
:
type
[
httpretty
.
httpretty
],
):
)
->
None
:
http
.
disable
()
http
.
disable
()
locker
=
Locker
(
locker
=
Locker
(
...
@@ -141,7 +141,7 @@ def test_lock_no_update(
...
@@ -141,7 +141,7 @@ def test_lock_no_update(
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
poetry_with_old_lockfile
:
Poetry
,
poetry_with_old_lockfile
:
Poetry
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
repo
.
add_package
(
get_package
(
"sampleproject"
,
"1.3.1"
))
repo
.
add_package
(
get_package
(
"sampleproject"
,
"1.3.1"
))
repo
.
add_package
(
get_package
(
"sampleproject"
,
"2.0.0"
))
repo
.
add_package
(
get_package
(
"sampleproject"
,
"2.0.0"
))
...
@@ -178,7 +178,7 @@ def test_lock_no_update_path_dependencies(
...
@@ -178,7 +178,7 @@ def test_lock_no_update_path_dependencies(
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
poetry_with_nested_path_deps_old_lockfile
:
Poetry
,
poetry_with_nested_path_deps_old_lockfile
:
Poetry
,
repo
:
TestRepository
,
repo
:
TestRepository
,
):
)
->
None
:
"""
"""
The lock file contains a variant of the directory dependency "quix" that does
The lock file contains a variant of the directory dependency "quix" that does
not depend on "sampleproject". Although the version of "quix" has not been changed,
not depend on "sampleproject". Although the version of "quix" has not been changed,
...
@@ -214,7 +214,7 @@ def test_lock_path_dependency_does_not_exist(
...
@@ -214,7 +214,7 @@ def test_lock_path_dependency_does_not_exist(
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
project
:
str
,
project
:
str
,
update
:
bool
,
update
:
bool
,
):
)
->
None
:
poetry
=
_project_factory
(
project
,
project_factory
,
fixture_dir
)
poetry
=
_project_factory
(
project
,
project_factory
,
fixture_dir
)
locker
=
Locker
(
locker
=
Locker
(
lock
=
poetry
.
pyproject
.
file
.
path
.
parent
/
"poetry.lock"
,
lock
=
poetry
.
pyproject
.
file
.
path
.
parent
/
"poetry.lock"
,
...
@@ -242,7 +242,7 @@ def test_lock_path_dependency_deleted_from_pyproject(
...
@@ -242,7 +242,7 @@ def test_lock_path_dependency_deleted_from_pyproject(
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
project
:
str
,
project
:
str
,
update
:
bool
,
update
:
bool
,
):
)
->
None
:
poetry
=
_project_factory
(
project
,
project_factory
,
fixture_dir
)
poetry
=
_project_factory
(
project
,
project_factory
,
fixture_dir
)
locker
=
Locker
(
locker
=
Locker
(
lock
=
poetry
.
pyproject
.
file
.
path
.
parent
/
"poetry.lock"
,
lock
=
poetry
.
pyproject
.
file
.
path
.
parent
/
"poetry.lock"
,
...
...
tests/console/commands/test_new.py
View file @
99f106c5
...
@@ -156,7 +156,7 @@ def test_command_new(
...
@@ -156,7 +156,7 @@ def test_command_new(
include_from
:
str
|
None
,
include_from
:
str
|
None
,
tester
:
CommandTester
,
tester
:
CommandTester
,
tmp_path
:
Path
,
tmp_path
:
Path
,
):
)
->
None
:
path
=
tmp_path
/
directory
path
=
tmp_path
/
directory
options
.
append
(
str
(
path
))
options
.
append
(
str
(
path
))
tester
.
execute
(
" "
.
join
(
options
))
tester
.
execute
(
" "
.
join
(
options
))
...
@@ -166,7 +166,7 @@ def test_command_new(
...
@@ -166,7 +166,7 @@ def test_command_new(
@pytest.mark.parametrize
((
"fmt"
,),
[(
None
,),
(
"md"
,),
(
"rst"
,),
(
"adoc"
,),
(
"creole"
,)])
@pytest.mark.parametrize
((
"fmt"
,),
[(
None
,),
(
"md"
,),
(
"rst"
,),
(
"adoc"
,),
(
"creole"
,)])
def
test_command_new_with_readme
(
def
test_command_new_with_readme
(
fmt
:
str
|
None
,
tester
:
CommandTester
,
tmp_path
:
Path
fmt
:
str
|
None
,
tester
:
CommandTester
,
tmp_path
:
Path
):
)
->
None
:
package
=
"package"
package
=
"package"
path
=
tmp_path
/
package
path
=
tmp_path
/
package
options
=
[
path
.
as_posix
()]
options
=
[
path
.
as_posix
()]
...
@@ -194,7 +194,7 @@ def test_respect_prefer_active_on_new(
...
@@ -194,7 +194,7 @@ def test_respect_prefer_active_on_new(
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
tester
:
CommandTester
,
tester
:
CommandTester
,
tmp_path
:
Path
,
tmp_path
:
Path
,
):
)
->
None
:
from
poetry.utils.env
import
GET_PYTHON_VERSION_ONELINER
from
poetry.utils.env
import
GET_PYTHON_VERSION_ONELINER
orig_check_output
=
subprocess
.
check_output
orig_check_output
=
subprocess
.
check_output
...
...
tests/console/commands/test_publish.py
View file @
99f106c5
...
@@ -23,7 +23,7 @@ def test_publish_returns_non_zero_code_for_upload_errors(
...
@@ -23,7 +23,7 @@ def test_publish_returns_non_zero_code_for_upload_errors(
app
:
PoetryTestApplication
,
app
:
PoetryTestApplication
,
app_tester
:
ApplicationTester
,
app_tester
:
ApplicationTester
,
http
:
type
[
httpretty
.
httpretty
],
http
:
type
[
httpretty
.
httpretty
],
):
)
->
None
:
http
.
register_uri
(
http
.
register_uri
(
http
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
400
,
body
=
"Bad Request"
http
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
400
,
body
=
"Bad Request"
)
)
...
@@ -48,7 +48,7 @@ def test_publish_returns_non_zero_code_for_connection_errors(
...
@@ -48,7 +48,7 @@ def test_publish_returns_non_zero_code_for_connection_errors(
app
:
PoetryTestApplication
,
app
:
PoetryTestApplication
,
app_tester
:
ApplicationTester
,
app_tester
:
ApplicationTester
,
http
:
type
[
httpretty
.
httpretty
],
http
:
type
[
httpretty
.
httpretty
],
):
)
->
None
:
def
request_callback
(
*
_
:
Any
,
**
__
:
Any
)
->
None
:
def
request_callback
(
*
_
:
Any
,
**
__
:
Any
)
->
None
:
raise
requests
.
ConnectionError
()
raise
requests
.
ConnectionError
()
...
@@ -65,7 +65,9 @@ def test_publish_returns_non_zero_code_for_connection_errors(
...
@@ -65,7 +65,9 @@ def test_publish_returns_non_zero_code_for_connection_errors(
assert
expected
in
app_tester
.
io
.
fetch_error
()
assert
expected
in
app_tester
.
io
.
fetch_error
()
def
test_publish_with_cert
(
app_tester
:
ApplicationTester
,
mocker
:
MockerFixture
):
def
test_publish_with_cert
(
app_tester
:
ApplicationTester
,
mocker
:
MockerFixture
)
->
None
:
publisher_publish
=
mocker
.
patch
(
"poetry.publishing.Publisher.publish"
)
publisher_publish
=
mocker
.
patch
(
"poetry.publishing.Publisher.publish"
)
app_tester
.
execute
(
"publish --cert path/to/ca.pem"
)
app_tester
.
execute
(
"publish --cert path/to/ca.pem"
)
...
@@ -75,7 +77,9 @@ def test_publish_with_cert(app_tester: ApplicationTester, mocker: MockerFixture)
...
@@ -75,7 +77,9 @@ def test_publish_with_cert(app_tester: ApplicationTester, mocker: MockerFixture)
]
==
publisher_publish
.
call_args
]
==
publisher_publish
.
call_args
def
test_publish_with_client_cert
(
app_tester
:
ApplicationTester
,
mocker
:
MockerFixture
):
def
test_publish_with_client_cert
(
app_tester
:
ApplicationTester
,
mocker
:
MockerFixture
)
->
None
:
publisher_publish
=
mocker
.
patch
(
"poetry.publishing.Publisher.publish"
)
publisher_publish
=
mocker
.
patch
(
"poetry.publishing.Publisher.publish"
)
app_tester
.
execute
(
"publish --client-cert path/to/client.pem"
)
app_tester
.
execute
(
"publish --client-cert path/to/client.pem"
)
...
@@ -94,7 +98,7 @@ def test_publish_with_client_cert(app_tester: ApplicationTester, mocker: MockerF
...
@@ -94,7 +98,7 @@ def test_publish_with_client_cert(app_tester: ApplicationTester, mocker: MockerF
)
)
def
test_publish_dry_run_skip_existing
(
def
test_publish_dry_run_skip_existing
(
app_tester
:
ApplicationTester
,
http
:
type
[
httpretty
.
httpretty
],
options
:
str
app_tester
:
ApplicationTester
,
http
:
type
[
httpretty
.
httpretty
],
options
:
str
):
)
->
None
:
http
.
register_uri
(
http
.
register_uri
(
http
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
409
,
body
=
"Conflict"
http
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
409
,
body
=
"Conflict"
)
)
...
@@ -113,7 +117,7 @@ def test_publish_dry_run_skip_existing(
...
@@ -113,7 +117,7 @@ def test_publish_dry_run_skip_existing(
def
test_skip_existing_output
(
def
test_skip_existing_output
(
app_tester
:
ApplicationTester
,
http
:
type
[
httpretty
.
httpretty
]
app_tester
:
ApplicationTester
,
http
:
type
[
httpretty
.
httpretty
]
):
)
->
None
:
http
.
register_uri
(
http
.
register_uri
(
http
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
409
,
body
=
"Conflict"
http
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
409
,
body
=
"Conflict"
)
)
...
...
tests/console/commands/test_remove.py
View file @
99f106c5
...
@@ -48,7 +48,7 @@ def test_remove_without_specific_group_removes_from_all_groups(
...
@@ -48,7 +48,7 @@ def test_remove_without_specific_group_removes_from_all_groups(
repo
:
TestRepository
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
installed
:
Repository
,
installed
:
Repository
,
):
)
->
None
:
"""
"""
Removing without specifying a group removes packages from all groups.
Removing without specifying a group removes packages from all groups.
"""
"""
...
@@ -105,7 +105,7 @@ def test_remove_without_specific_group_removes_from_specific_groups(
...
@@ -105,7 +105,7 @@ def test_remove_without_specific_group_removes_from_specific_groups(
repo
:
TestRepository
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
installed
:
Repository
,
installed
:
Repository
,
):
)
->
None
:
"""
"""
Removing with a specific group given removes packages only from this group.
Removing with a specific group given removes packages only from this group.
"""
"""
...
@@ -162,7 +162,7 @@ def test_remove_does_not_live_empty_groups(
...
@@ -162,7 +162,7 @@ def test_remove_does_not_live_empty_groups(
repo
:
TestRepository
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
installed
:
Repository
,
installed
:
Repository
,
):
)
->
None
:
"""
"""
Empty groups are automatically discarded after package removal.
Empty groups are automatically discarded after package removal.
"""
"""
...
@@ -208,7 +208,7 @@ def test_remove_canonicalized_named_removes_dependency_correctly(
...
@@ -208,7 +208,7 @@ def test_remove_canonicalized_named_removes_dependency_correctly(
repo
:
TestRepository
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
installed
:
Repository
,
installed
:
Repository
,
):
)
->
None
:
"""
"""
Removing a dependency using a canonicalized named removes the dependency.
Removing a dependency using a canonicalized named removes the dependency.
"""
"""
...
@@ -267,7 +267,7 @@ def test_remove_command_should_not_write_changes_upon_installer_errors(
...
@@ -267,7 +267,7 @@ def test_remove_command_should_not_write_changes_upon_installer_errors(
repo
:
TestRepository
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
repo
.
add_package
(
Package
(
"foo"
,
"2.0.0"
))
repo
.
add_package
(
Package
(
"foo"
,
"2.0.0"
))
command_tester_factory
(
"add"
)
.
execute
(
"foo"
)
command_tester_factory
(
"add"
)
.
execute
(
"foo"
)
...
@@ -285,7 +285,7 @@ def test_remove_with_dry_run_keep_files_intact(
...
@@ -285,7 +285,7 @@ def test_remove_with_dry_run_keep_files_intact(
poetry_with_up_to_date_lockfile
:
Poetry
,
poetry_with_up_to_date_lockfile
:
Poetry
,
repo
:
TestRepository
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
):
)
->
None
:
tester
=
command_tester_factory
(
"remove"
,
poetry
=
poetry_with_up_to_date_lockfile
)
tester
=
command_tester_factory
(
"remove"
,
poetry
=
poetry_with_up_to_date_lockfile
)
original_pyproject_content
=
poetry_with_up_to_date_lockfile
.
file
.
read
()
original_pyproject_content
=
poetry_with_up_to_date_lockfile
.
file
.
read
()
...
...
tests/console/commands/test_run.py
View file @
99f106c5
...
@@ -45,14 +45,14 @@ def poetry_with_scripts(
...
@@ -45,14 +45,14 @@ def poetry_with_scripts(
)
)
def
test_run_passes_all_args
(
app_tester
:
ApplicationTester
,
env
:
MockEnv
):
def
test_run_passes_all_args
(
app_tester
:
ApplicationTester
,
env
:
MockEnv
)
->
None
:
app_tester
.
execute
(
"run python -V"
)
app_tester
.
execute
(
"run python -V"
)
assert
[[
"python"
,
"-V"
]]
==
env
.
executed
assert
[[
"python"
,
"-V"
]]
==
env
.
executed
def
test_run_keeps_options_passed_before_command
(
def
test_run_keeps_options_passed_before_command
(
app_tester
:
ApplicationTester
,
env
:
MockEnv
app_tester
:
ApplicationTester
,
env
:
MockEnv
):
)
->
None
:
app_tester
.
execute
(
"-V --no-ansi run python"
,
decorated
=
True
)
app_tester
.
execute
(
"-V --no-ansi run python"
,
decorated
=
True
)
assert
not
app_tester
.
io
.
is_decorated
()
assert
not
app_tester
.
io
.
is_decorated
()
...
@@ -64,7 +64,7 @@ def test_run_keeps_options_passed_before_command(
...
@@ -64,7 +64,7 @@ def test_run_keeps_options_passed_before_command(
def
test_run_has_helpful_error_when_command_not_found
(
def
test_run_has_helpful_error_when_command_not_found
(
app_tester
:
ApplicationTester
,
env
:
MockEnv
,
capfd
:
pytest
.
CaptureFixture
[
str
]
app_tester
:
ApplicationTester
,
env
:
MockEnv
,
capfd
:
pytest
.
CaptureFixture
[
str
]
):
)
->
None
:
nonexistent_command
=
"nonexistent-command"
nonexistent_command
=
"nonexistent-command"
env
.
_execute
=
True
env
.
_execute
=
True
app_tester
.
execute
(
f
"run {nonexistent_command}"
)
app_tester
.
execute
(
f
"run {nonexistent_command}"
)
...
@@ -94,7 +94,7 @@ def test_run_has_helpful_error_when_command_not_found(
...
@@ -94,7 +94,7 @@ def test_run_has_helpful_error_when_command_not_found(
def
test_run_console_scripts_of_editable_dependencies_on_windows
(
def
test_run_console_scripts_of_editable_dependencies_on_windows
(
tmp_venv
:
VirtualEnv
,
tmp_venv
:
VirtualEnv
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
):
)
->
None
:
"""
"""
On Windows, Poetry installs console scripts of editable dependencies by creating
On Windows, Poetry installs console scripts of editable dependencies by creating
in the environment's `Scripts/` directory both:
in the environment's `Scripts/` directory both:
...
...
tests/console/commands/test_shell.py
View file @
99f106c5
...
@@ -20,7 +20,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
...
@@ -20,7 +20,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
return
command_tester_factory
(
"shell"
)
return
command_tester_factory
(
"shell"
)
def
test_shell
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_shell
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
shell_activate
=
mocker
.
patch
(
"poetry.utils.shell.Shell.activate"
)
shell_activate
=
mocker
.
patch
(
"poetry.utils.shell.Shell.activate"
)
tester
.
execute
()
tester
.
execute
()
...
@@ -32,7 +32,7 @@ def test_shell(tester: CommandTester, mocker: MockerFixture):
...
@@ -32,7 +32,7 @@ def test_shell(tester: CommandTester, mocker: MockerFixture):
assert
tester
.
status_code
==
0
assert
tester
.
status_code
==
0
def
test_shell_already_active
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_shell_already_active
(
tester
:
CommandTester
,
mocker
:
MockerFixture
)
->
None
:
os
.
environ
[
"POETRY_ACTIVE"
]
=
"1"
os
.
environ
[
"POETRY_ACTIVE"
]
=
"1"
shell_activate
=
mocker
.
patch
(
"poetry.utils.shell.Shell.activate"
)
shell_activate
=
mocker
.
patch
(
"poetry.utils.shell.Shell.activate"
)
...
@@ -71,7 +71,7 @@ def test__is_venv_activated(
...
@@ -71,7 +71,7 @@ def test__is_venv_activated(
real_prefix
:
str
|
None
,
real_prefix
:
str
|
None
,
prefix
:
str
,
prefix
:
str
,
expected
:
bool
,
expected
:
bool
,
):
)
->
None
:
mocker
.
patch
.
object
(
tester
.
command
.
env
,
"_path"
,
Path
(
"foobar"
))
mocker
.
patch
.
object
(
tester
.
command
.
env
,
"_path"
,
Path
(
"foobar"
))
mocker
.
patch
(
"sys.prefix"
,
prefix
)
mocker
.
patch
(
"sys.prefix"
,
prefix
)
...
...
tests/console/commands/test_update.py
View file @
99f106c5
...
@@ -40,7 +40,7 @@ def test_update_with_dry_run_keep_files_intact(
...
@@ -40,7 +40,7 @@ def test_update_with_dry_run_keep_files_intact(
poetry_with_up_to_date_lockfile
:
Poetry
,
poetry_with_up_to_date_lockfile
:
Poetry
,
repo
:
TestRepository
,
repo
:
TestRepository
,
command_tester_factory
:
CommandTesterFactory
,
command_tester_factory
:
CommandTesterFactory
,
):
)
->
None
:
tester
=
command_tester_factory
(
"update"
,
poetry
=
poetry_with_up_to_date_lockfile
)
tester
=
command_tester_factory
(
"update"
,
poetry
=
poetry_with_up_to_date_lockfile
)
original_pyproject_content
=
poetry_with_up_to_date_lockfile
.
file
.
read
()
original_pyproject_content
=
poetry_with_up_to_date_lockfile
.
file
.
read
()
...
...
tests/console/commands/test_version.py
View file @
99f106c5
...
@@ -51,31 +51,31 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
...
@@ -51,31 +51,31 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
)
)
def
test_increment_version
(
def
test_increment_version
(
version
:
str
,
rule
:
str
,
expected
:
str
,
command
:
VersionCommand
version
:
str
,
rule
:
str
,
expected
:
str
,
command
:
VersionCommand
):
)
->
None
:
assert
command
.
increment_version
(
version
,
rule
)
.
text
==
expected
assert
command
.
increment_version
(
version
,
rule
)
.
text
==
expected
def
test_version_show
(
tester
:
CommandTester
):
def
test_version_show
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
()
tester
.
execute
()
assert
tester
.
io
.
fetch_output
()
==
"simple-project 1.2.3
\n
"
assert
tester
.
io
.
fetch_output
()
==
"simple-project 1.2.3
\n
"
def
test_short_version_show
(
tester
:
CommandTester
):
def
test_short_version_show
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
(
"--short"
)
tester
.
execute
(
"--short"
)
assert
tester
.
io
.
fetch_output
()
==
"1.2.3
\n
"
assert
tester
.
io
.
fetch_output
()
==
"1.2.3
\n
"
def
test_version_update
(
tester
:
CommandTester
):
def
test_version_update
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
(
"2.0.0"
)
tester
.
execute
(
"2.0.0"
)
assert
tester
.
io
.
fetch_output
()
==
"Bumping version from 1.2.3 to 2.0.0
\n
"
assert
tester
.
io
.
fetch_output
()
==
"Bumping version from 1.2.3 to 2.0.0
\n
"
def
test_short_version_update
(
tester
:
CommandTester
):
def
test_short_version_update
(
tester
:
CommandTester
)
->
None
:
tester
.
execute
(
"--short 2.0.0"
)
tester
.
execute
(
"--short 2.0.0"
)
assert
tester
.
io
.
fetch_output
()
==
"2.0.0
\n
"
assert
tester
.
io
.
fetch_output
()
==
"2.0.0
\n
"
def
test_dry_run
(
tester
:
CommandTester
):
def
test_dry_run
(
tester
:
CommandTester
)
->
None
:
old_pyproject
=
tester
.
command
.
poetry
.
file
.
path
.
read_text
()
old_pyproject
=
tester
.
command
.
poetry
.
file
.
path
.
read_text
()
tester
.
execute
(
"--dry-run major"
)
tester
.
execute
(
"--dry-run major"
)
...
...
tests/console/test_application.py
View file @
99f106c5
...
@@ -39,7 +39,7 @@ def with_add_command_plugin(mocker: MockerFixture) -> None:
...
@@ -39,7 +39,7 @@ def with_add_command_plugin(mocker: MockerFixture) -> None:
mock_metadata_entry_points
(
mocker
,
AddCommandPlugin
)
mock_metadata_entry_points
(
mocker
,
AddCommandPlugin
)
def
test_application_with_plugins
(
with_add_command_plugin
:
None
):
def
test_application_with_plugins
(
with_add_command_plugin
:
None
)
->
None
:
app
=
Application
()
app
=
Application
()
tester
=
ApplicationTester
(
app
)
tester
=
ApplicationTester
(
app
)
...
@@ -49,7 +49,7 @@ def test_application_with_plugins(with_add_command_plugin: None):
...
@@ -49,7 +49,7 @@ def test_application_with_plugins(with_add_command_plugin: None):
assert
tester
.
status_code
==
0
assert
tester
.
status_code
==
0
def
test_application_with_plugins_disabled
(
with_add_command_plugin
:
None
):
def
test_application_with_plugins_disabled
(
with_add_command_plugin
:
None
)
->
None
:
app
=
Application
()
app
=
Application
()
tester
=
ApplicationTester
(
app
)
tester
=
ApplicationTester
(
app
)
...
@@ -59,7 +59,7 @@ def test_application_with_plugins_disabled(with_add_command_plugin: None):
...
@@ -59,7 +59,7 @@ def test_application_with_plugins_disabled(with_add_command_plugin: None):
assert
tester
.
status_code
==
0
assert
tester
.
status_code
==
0
def
test_application_execute_plugin_command
(
with_add_command_plugin
:
None
):
def
test_application_execute_plugin_command
(
with_add_command_plugin
:
None
)
->
None
:
app
=
Application
()
app
=
Application
()
tester
=
ApplicationTester
(
app
)
tester
=
ApplicationTester
(
app
)
...
@@ -71,7 +71,7 @@ def test_application_execute_plugin_command(with_add_command_plugin: None):
...
@@ -71,7 +71,7 @@ def test_application_execute_plugin_command(with_add_command_plugin: None):
def
test_application_execute_plugin_command_with_plugins_disabled
(
def
test_application_execute_plugin_command_with_plugins_disabled
(
with_add_command_plugin
:
None
,
with_add_command_plugin
:
None
,
):
)
->
None
:
app
=
Application
()
app
=
Application
()
tester
=
ApplicationTester
(
app
)
tester
=
ApplicationTester
(
app
)
...
@@ -83,7 +83,7 @@ def test_application_execute_plugin_command_with_plugins_disabled(
...
@@ -83,7 +83,7 @@ def test_application_execute_plugin_command_with_plugins_disabled(
@pytest.mark.parametrize
(
"disable_cache"
,
[
True
,
False
])
@pytest.mark.parametrize
(
"disable_cache"
,
[
True
,
False
])
def
test_application_verify_source_cache_flag
(
disable_cache
:
bool
):
def
test_application_verify_source_cache_flag
(
disable_cache
:
bool
)
->
None
:
app
=
Application
()
app
=
Application
()
tester
=
ApplicationTester
(
app
)
tester
=
ApplicationTester
(
app
)
...
...
tests/installation/test_chef.py
View file @
99f106c5
...
@@ -68,7 +68,7 @@ def test_prepare_directory(
...
@@ -68,7 +68,7 @@ def test_prepare_directory(
config_cache_dir
:
Path
,
config_cache_dir
:
Path
,
artifact_cache
:
ArtifactCache
,
artifact_cache
:
ArtifactCache
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
chef
=
Chef
(
chef
=
Chef
(
artifact_cache
,
EnvManager
.
get_system_env
(),
Factory
.
create_pool
(
config
)
artifact_cache
,
EnvManager
.
get_system_env
(),
Factory
.
create_pool
(
config
)
)
)
...
@@ -107,7 +107,7 @@ def test_prepare_directory_editable(
...
@@ -107,7 +107,7 @@ def test_prepare_directory_editable(
config_cache_dir
:
Path
,
config_cache_dir
:
Path
,
artifact_cache
:
ArtifactCache
,
artifact_cache
:
ArtifactCache
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
chef
=
Chef
(
chef
=
Chef
(
artifact_cache
,
EnvManager
.
get_system_env
(),
Factory
.
create_pool
(
config
)
artifact_cache
,
EnvManager
.
get_system_env
(),
Factory
.
create_pool
(
config
)
)
)
...
...
tests/installation/test_executor.py
View file @
99f106c5
...
@@ -203,7 +203,7 @@ def test_execute_executes_a_batch_of_operations(
...
@@ -203,7 +203,7 @@ def test_execute_executes_a_batch_of_operations(
env
:
MockEnv
,
env
:
MockEnv
,
copy_wheel
:
Callable
[[],
Path
],
copy_wheel
:
Callable
[[],
Path
],
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
wheel_install
=
mocker
.
patch
.
object
(
WheelInstaller
,
"install"
)
wheel_install
=
mocker
.
patch
.
object
(
WheelInstaller
,
"install"
)
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
...
@@ -314,7 +314,7 @@ def test_execute_prints_warning_for_yanked_package(
...
@@ -314,7 +314,7 @@ def test_execute_prints_warning_for_yanked_package(
env
:
MockEnv
,
env
:
MockEnv
,
operations
:
list
[
Operation
],
operations
:
list
[
Operation
],
has_warning
:
bool
,
has_warning
:
bool
,
):
)
->
None
:
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
...
@@ -345,7 +345,7 @@ def test_execute_prints_warning_for_invalid_wheels(
...
@@ -345,7 +345,7 @@ def test_execute_prints_warning_for_invalid_wheels(
tmp_path
:
Path
,
tmp_path
:
Path
,
mock_file_downloads
:
None
,
mock_file_downloads
:
None
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
...
@@ -404,7 +404,7 @@ def test_execute_shows_skipped_operations_if_verbose(
...
@@ -404,7 +404,7 @@ def test_execute_shows_skipped_operations_if_verbose(
io
:
BufferedIO
,
io
:
BufferedIO
,
config_cache_dir
:
Path
,
config_cache_dir
:
Path
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
config
.
merge
({
"cache-dir"
:
config_cache_dir
.
as_posix
()})
config
.
merge
({
"cache-dir"
:
config_cache_dir
.
as_posix
()})
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
...
@@ -432,7 +432,7 @@ def test_execute_should_show_errors(
...
@@ -432,7 +432,7 @@ def test_execute_should_show_errors(
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
io
:
BufferedIO
,
io
:
BufferedIO
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
.
verbose
()
executor
.
verbose
()
...
@@ -460,7 +460,7 @@ def test_execute_works_with_ansi_output(
...
@@ -460,7 +460,7 @@ def test_execute_works_with_ansi_output(
tmp_path
:
Path
,
tmp_path
:
Path
,
mock_file_downloads
:
None
,
mock_file_downloads
:
None
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
executor
=
Executor
(
env
,
pool
,
config
,
io_decorated
)
executor
=
Executor
(
env
,
pool
,
config
,
io_decorated
)
...
@@ -497,7 +497,7 @@ def test_execute_works_with_no_ansi_output(
...
@@ -497,7 +497,7 @@ def test_execute_works_with_no_ansi_output(
tmp_path
:
Path
,
tmp_path
:
Path
,
mock_file_downloads
:
None
,
mock_file_downloads
:
None
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
config
.
merge
({
"cache-dir"
:
str
(
tmp_path
)})
executor
=
Executor
(
env
,
pool
,
config
,
io_not_decorated
)
executor
=
Executor
(
env
,
pool
,
config
,
io_not_decorated
)
...
@@ -525,7 +525,7 @@ def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_inter
...
@@ -525,7 +525,7 @@ def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_inter
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
io
:
BufferedIO
,
io
:
BufferedIO
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
.
verbose
()
executor
.
verbose
()
...
@@ -550,7 +550,7 @@ def test_execute_should_gracefully_handle_io_error(
...
@@ -550,7 +550,7 @@ def test_execute_should_gracefully_handle_io_error(
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
io
:
BufferedIO
,
io
:
BufferedIO
,
env
:
MockEnv
,
env
:
MockEnv
,
):
)
->
None
:
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
=
Executor
(
env
,
pool
,
config
,
io
)
executor
.
verbose
()
executor
.
verbose
()
...
@@ -584,7 +584,7 @@ def test_executor_should_delete_incomplete_downloads(
...
@@ -584,7 +584,7 @@ def test_executor_should_delete_incomplete_downloads(
mock_file_downloads
:
None
,
mock_file_downloads
:
None
,
env
:
MockEnv
,
env
:
MockEnv
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
fixture
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
fixture
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
destination_fixture
=
tmp_path
/
"tomlkit-0.5.3-py2.py3-none-any.whl"
destination_fixture
=
tmp_path
/
"tomlkit-0.5.3-py2.py3-none-any.whl"
shutil
.
copyfile
(
str
(
fixture
),
str
(
destination_fixture
))
shutil
.
copyfile
(
str
(
fixture
),
str
(
destination_fixture
))
...
@@ -613,7 +613,7 @@ def test_executor_should_delete_incomplete_downloads(
...
@@ -613,7 +613,7 @@ def test_executor_should_delete_incomplete_downloads(
def
verify_installed_distribution
(
def
verify_installed_distribution
(
venv
:
VirtualEnv
,
package
:
Package
,
url_reference
:
dict
[
str
,
Any
]
|
None
=
None
venv
:
VirtualEnv
,
package
:
Package
,
url_reference
:
dict
[
str
,
Any
]
|
None
=
None
):
)
->
None
:
distributions
=
list
(
venv
.
site_packages
.
distributions
(
name
=
package
.
name
))
distributions
=
list
(
venv
.
site_packages
.
distributions
(
name
=
package
.
name
))
assert
len
(
distributions
)
==
1
assert
len
(
distributions
)
==
1
...
@@ -660,7 +660,7 @@ def test_executor_should_not_write_pep610_url_references_for_cached_package(
...
@@ -660,7 +660,7 @@ def test_executor_should_not_write_pep610_url_references_for_cached_package(
pool
:
RepositoryPool
,
pool
:
RepositoryPool
,
config
:
Config
,
config
:
Config
,
io
:
BufferedIO
,
io
:
BufferedIO
,
):
)
->
None
:
link_cached
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
link_cached
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
package
.
files
=
[
package
.
files
=
[
{
{
...
@@ -685,7 +685,7 @@ def test_executor_should_write_pep610_url_references_for_wheel_files(
...
@@ -685,7 +685,7 @@ def test_executor_should_write_pep610_url_references_for_wheel_files(
config
:
Config
,
config
:
Config
,
io
:
BufferedIO
,
io
:
BufferedIO
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
url
=
(
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
)
.
resolve
()
url
=
(
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
)
.
resolve
()
package
=
Package
(
"demo"
,
"0.1.0"
,
source_type
=
"file"
,
source_url
=
url
.
as_posix
())
package
=
Package
(
"demo"
,
"0.1.0"
,
source_type
=
"file"
,
source_url
=
url
.
as_posix
())
# Set package.files so the executor will attempt to hash the package
# Set package.files so the executor will attempt to hash the package
...
@@ -718,7 +718,7 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_files(
...
@@ -718,7 +718,7 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_files(
config
:
Config
,
config
:
Config
,
io
:
BufferedIO
,
io
:
BufferedIO
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
url
=
(
fixture_dir
(
"distributions"
)
/
"demo-0.1.0.tar.gz"
)
.
resolve
()
url
=
(
fixture_dir
(
"distributions"
)
/
"demo-0.1.0.tar.gz"
)
.
resolve
()
package
=
Package
(
"demo"
,
"0.1.0"
,
source_type
=
"file"
,
source_url
=
url
.
as_posix
())
package
=
Package
(
"demo"
,
"0.1.0"
,
source_type
=
"file"
,
source_url
=
url
.
as_posix
())
# Set package.files so the executor will attempt to hash the package
# Set package.files so the executor will attempt to hash the package
...
@@ -754,7 +754,7 @@ def test_executor_should_write_pep610_url_references_for_directories(
...
@@ -754,7 +754,7 @@ def test_executor_should_write_pep610_url_references_for_directories(
wheel
:
Path
,
wheel
:
Path
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
url
=
(
fixture_dir
(
"git"
)
/
"github.com"
/
"demo"
/
"demo"
)
.
resolve
()
url
=
(
fixture_dir
(
"git"
)
/
"github.com"
/
"demo"
/
"demo"
)
.
resolve
()
package
=
Package
(
package
=
Package
(
"demo"
,
"0.1.2"
,
source_type
=
"directory"
,
source_url
=
url
.
as_posix
()
"demo"
,
"0.1.2"
,
source_type
=
"directory"
,
source_url
=
url
.
as_posix
()
...
@@ -782,7 +782,7 @@ def test_executor_should_write_pep610_url_references_for_editable_directories(
...
@@ -782,7 +782,7 @@ def test_executor_should_write_pep610_url_references_for_editable_directories(
wheel
:
Path
,
wheel
:
Path
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
url
=
(
fixture_dir
(
"git"
)
/
"github.com"
/
"demo"
/
"demo"
)
.
resolve
()
url
=
(
fixture_dir
(
"git"
)
/
"github.com"
/
"demo"
/
"demo"
)
.
resolve
()
package
=
Package
(
package
=
Package
(
"demo"
,
"demo"
,
...
@@ -815,7 +815,7 @@ def test_executor_should_write_pep610_url_references_for_wheel_urls(
...
@@ -815,7 +815,7 @@ def test_executor_should_write_pep610_url_references_for_wheel_urls(
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
is_artifact_cached
:
bool
,
is_artifact_cached
:
bool
,
):
)
->
None
:
if
is_artifact_cached
:
if
is_artifact_cached
:
link_cached
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
link_cached
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
mocker
.
patch
(
mocker
.
patch
(
...
@@ -887,7 +887,7 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_urls(
...
@@ -887,7 +887,7 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_urls(
is_wheel_cached
:
bool
,
is_wheel_cached
:
bool
,
expect_artifact_building
:
bool
,
expect_artifact_building
:
bool
,
expect_artifact_download
:
bool
,
expect_artifact_download
:
bool
,
):
)
->
None
:
built_wheel
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
built_wheel
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
mock_prepare
=
mocker
.
patch
(
mock_prepare
=
mocker
.
patch
(
"poetry.installation.chef.Chef._prepare"
,
"poetry.installation.chef.Chef._prepare"
,
...
@@ -899,7 +899,9 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_urls(
...
@@ -899,7 +899,9 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_urls(
cached_sdist
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0.tar.gz"
cached_sdist
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0.tar.gz"
cached_wheel
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
cached_wheel
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.0-py2.py3-none-any.whl"
def
mock_get_cached_archive_for_link_func
(
_
:
Link
,
*
,
strict
:
bool
,
**
__
:
Any
):
def
mock_get_cached_archive_for_link_func
(
_
:
Link
,
*
,
strict
:
bool
,
**
__
:
Any
)
->
None
:
if
is_wheel_cached
and
not
strict
:
if
is_wheel_cached
and
not
strict
:
return
cached_wheel
return
cached_wheel
if
is_sdist_cached
:
if
is_sdist_cached
:
...
@@ -966,7 +968,7 @@ def test_executor_should_write_pep610_url_references_for_git(
...
@@ -966,7 +968,7 @@ def test_executor_should_write_pep610_url_references_for_git(
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
is_artifact_cached
:
bool
,
is_artifact_cached
:
bool
,
):
)
->
None
:
if
is_artifact_cached
:
if
is_artifact_cached
:
link_cached
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.2-py2.py3-none-any.whl"
link_cached
=
fixture_dir
(
"distributions"
)
/
"demo-0.1.2-py2.py3-none-any.whl"
mocker
.
patch
(
mocker
.
patch
(
...
@@ -1029,7 +1031,7 @@ def test_executor_should_write_pep610_url_references_for_editable_git(
...
@@ -1029,7 +1031,7 @@ def test_executor_should_write_pep610_url_references_for_editable_git(
wheel
:
Path
,
wheel
:
Path
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
source_resolved_reference
=
"123456"
source_resolved_reference
=
"123456"
source_url
=
"https://github.com/demo/demo.git"
source_url
=
"https://github.com/demo/demo.git"
...
@@ -1106,7 +1108,7 @@ def test_executor_should_write_pep610_url_references_for_git_with_subdirectories
...
@@ -1106,7 +1108,7 @@ def test_executor_should_write_pep610_url_references_for_git_with_subdirectories
io
:
BufferedIO
,
io
:
BufferedIO
,
mock_file_downloads
:
None
,
mock_file_downloads
:
None
,
wheel
:
Path
,
wheel
:
Path
,
):
)
->
None
:
package
=
Package
(
package
=
Package
(
"demo"
,
"demo"
,
"0.1.2"
,
"0.1.2"
,
...
@@ -1159,7 +1161,7 @@ def test_executor_should_be_initialized_with_correct_workers(
...
@@ -1159,7 +1161,7 @@ def test_executor_should_be_initialized_with_correct_workers(
cpu_count
:
int
|
None
,
cpu_count
:
int
|
None
,
side_effect
:
Exception
|
None
,
side_effect
:
Exception
|
None
,
expected_workers
:
int
,
expected_workers
:
int
,
):
)
->
None
:
config
.
merge
({
"installer"
:
{
"max-workers"
:
max_workers
}})
config
.
merge
({
"installer"
:
{
"max-workers"
:
max_workers
}})
mocker
.
patch
(
"os.cpu_count"
,
return_value
=
cpu_count
,
side_effect
=
side_effect
)
mocker
.
patch
(
"os.cpu_count"
,
return_value
=
cpu_count
,
side_effect
=
side_effect
)
...
@@ -1178,7 +1180,7 @@ def test_executor_fallback_on_poetry_create_error_without_wheel_installer(
...
@@ -1178,7 +1180,7 @@ def test_executor_fallback_on_poetry_create_error_without_wheel_installer(
mock_file_downloads
:
None
,
mock_file_downloads
:
None
,
env
:
MockEnv
,
env
:
MockEnv
,
fixture_dir
:
FixtureDirGetter
,
fixture_dir
:
FixtureDirGetter
,
):
)
->
None
:
mock_pip_install
=
mocker
.
patch
(
"poetry.installation.executor.pip_install"
)
mock_pip_install
=
mocker
.
patch
(
"poetry.installation.executor.pip_install"
)
mock_sdist_builder
=
mocker
.
patch
(
"poetry.core.masonry.builders.sdist.SdistBuilder"
)
mock_sdist_builder
=
mocker
.
patch
(
"poetry.core.masonry.builders.sdist.SdistBuilder"
)
mock_editable_builder
=
mocker
.
patch
(
mock_editable_builder
=
mocker
.
patch
(
...
...
tests/installation/test_installer.py
View file @
99f106c5
This diff is collapsed.
Click to expand it.
tests/integration/test_utils_vcs_git.py
View file @
99f106c5
...
@@ -112,7 +112,7 @@ def remote_default_branch(remote_default_ref: bytes) -> str:
...
@@ -112,7 +112,7 @@ def remote_default_branch(remote_default_ref: bytes) -> str:
# Regression test for https://github.com/python-poetry/poetry/issues/6722
# Regression test for https://github.com/python-poetry/poetry/issues/6722
def
test_use_system_git_client_from_environment_variables
():
def
test_use_system_git_client_from_environment_variables
()
->
None
:
os
.
environ
[
"POETRY_EXPERIMENTAL_SYSTEM_GIT_CLIENT"
]
=
"true"
os
.
environ
[
"POETRY_EXPERIMENTAL_SYSTEM_GIT_CLIENT"
]
=
"true"
assert
Git
.
is_using_legacy_client
()
assert
Git
.
is_using_legacy_client
()
...
@@ -132,7 +132,7 @@ def test_git_clone_default_branch_head(
...
@@ -132,7 +132,7 @@ def test_git_clone_default_branch_head(
remote_refs
:
FetchPackResult
,
remote_refs
:
FetchPackResult
,
remote_default_ref
:
bytes
,
remote_default_ref
:
bytes
,
mocker
:
MockerFixture
,
mocker
:
MockerFixture
,
):
)
->
None
:
spy
=
mocker
.
spy
(
Git
,
"_clone"
)
spy
=
mocker
.
spy
(
Git
,
"_clone"
)
spy_legacy
=
mocker
.
spy
(
Git
,
"_clone_legacy"
)
spy_legacy
=
mocker
.
spy
(
Git
,
"_clone_legacy"
)
...
@@ -143,7 +143,7 @@ def test_git_clone_default_branch_head(
...
@@ -143,7 +143,7 @@ def test_git_clone_default_branch_head(
spy
.
assert_called
()
spy
.
assert_called
()
def
test_git_clone_fails_for_non_existent_branch
(
source_url
:
str
):
def
test_git_clone_fails_for_non_existent_branch
(
source_url
:
str
)
->
None
:
branch
=
uuid
.
uuid4
()
.
hex
branch
=
uuid
.
uuid4
()
.
hex
with
pytest
.
raises
(
PoetryConsoleError
)
as
e
:
with
pytest
.
raises
(
PoetryConsoleError
)
as
e
:
...
@@ -152,7 +152,7 @@ def test_git_clone_fails_for_non_existent_branch(source_url: str):
...
@@ -152,7 +152,7 @@ def test_git_clone_fails_for_non_existent_branch(source_url: str):
assert
f
"Failed to clone {source_url} at '{branch}'"
in
str
(
e
.
value
)
assert
f
"Failed to clone {source_url} at '{branch}'"
in
str
(
e
.
value
)
def
test_git_clone_fails_for_non_existent_revision
(
source_url
:
str
):
def
test_git_clone_fails_for_non_existent_revision
(
source_url
:
str
)
->
None
:
revision
=
sha1
(
uuid
.
uuid4
()
.
bytes
)
.
hexdigest
()
revision
=
sha1
(
uuid
.
uuid4
()
.
bytes
)
.
hexdigest
()
with
pytest
.
raises
(
PoetryConsoleError
)
as
e
:
with
pytest
.
raises
(
PoetryConsoleError
)
as
e
:
...
...
tests/plugins/test_plugin_manager.py
View file @
99f106c5
from
__future__
import
annotations
from
__future__
import
annotations
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
import
pytest
import
pytest
...
@@ -17,6 +18,7 @@ from tests.helpers import mock_metadata_entry_points
...
@@ -17,6 +18,7 @@ from tests.helpers import mock_metadata_entry_points
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
cleo.io.io
import
IO
from
pytest_mock
import
MockerFixture
from
pytest_mock
import
MockerFixture
from
tests.conftest
import
Config
from
tests.conftest
import
Config
...
@@ -29,9 +31,9 @@ class ManagerFactory(Protocol):
...
@@ -29,9 +31,9 @@ class ManagerFactory(Protocol):
class
MyPlugin
(
Plugin
):
class
MyPlugin
(
Plugin
):
def
activate
(
self
,
poetry
:
Poetry
,
io
:
Buffered
IO
)
->
None
:
def
activate
(
self
,
poetry
:
Poetry
,
io
:
IO
)
->
None
:
io
.
write_line
(
"Setting readmes"
)
io
.
write_line
(
"Setting readmes"
)
poetry
.
package
.
readmes
=
(
"README.md"
,)
poetry
.
package
.
readmes
=
(
Path
(
"README.md"
)
,)
class
MyCommandPlugin
(
ApplicationPlugin
):
class
MyCommandPlugin
(
ApplicationPlugin
):
...
@@ -39,7 +41,7 @@ class MyCommandPlugin(ApplicationPlugin):
...
@@ -39,7 +41,7 @@ class MyCommandPlugin(ApplicationPlugin):
class
InvalidPlugin
:
class
InvalidPlugin
:
def
activate
(
self
,
poetry
:
Poetry
,
io
:
Buffered
IO
)
->
None
:
def
activate
(
self
,
poetry
:
Poetry
,
io
:
IO
)
->
None
:
io
.
write_line
(
"Updating version"
)
io
.
write_line
(
"Updating version"
)
poetry
.
package
.
version
=
"9.9.9"
poetry
.
package
.
version
=
"9.9.9"
...
@@ -59,7 +61,7 @@ def poetry(fixture_dir: FixtureDirGetter, config: Config) -> Poetry:
...
@@ -59,7 +61,7 @@ def poetry(fixture_dir: FixtureDirGetter, config: Config) -> Poetry:
@pytest.fixture
()
@pytest.fixture
()
def
io
()
->
Buffered
IO
:
def
io
()
->
IO
:
return
BufferedIO
()
return
BufferedIO
()
...
@@ -86,7 +88,7 @@ def test_load_plugins_and_activate(
...
@@ -86,7 +88,7 @@ def test_load_plugins_and_activate(
manager
.
load_plugins
()
manager
.
load_plugins
()
manager
.
activate
(
poetry
,
io
)
manager
.
activate
(
poetry
,
io
)
assert
poetry
.
package
.
readmes
==
(
"README.md"
,)
assert
poetry
.
package
.
readmes
==
(
Path
(
"README.md"
)
,)
assert
io
.
fetch_output
()
==
"Setting readmes
\n
"
assert
io
.
fetch_output
()
==
"Setting readmes
\n
"
...
...
tests/puzzle/test_provider.py
View file @
99f106c5
...
@@ -2,6 +2,7 @@ from __future__ import annotations
...
@@ -2,6 +2,7 @@ from __future__ import annotations
from
subprocess
import
CalledProcessError
from
subprocess
import
CalledProcessError
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
import
pytest
import
pytest
...
@@ -35,7 +36,7 @@ SOME_URL = "https://example.com/path.tar.gz"
...
@@ -35,7 +36,7 @@ SOME_URL = "https://example.com/path.tar.gz"
class
MockEnv
(
BaseMockEnv
):
class
MockEnv
(
BaseMockEnv
):
def
run
(
self
,
bin
:
str
,
*
args
:
str
)
->
None
:
def
run
(
self
,
bin
:
str
,
*
args
:
str
,
**
kwargs
:
Any
)
->
str
|
int
:
raise
EnvCommandError
(
CalledProcessError
(
1
,
"python"
,
output
=
""
))
raise
EnvCommandError
(
CalledProcessError
(
1
,
"python"
,
output
=
""
))
...
...
tests/puzzle/test_solver.py
View file @
99f106c5
...
@@ -3410,7 +3410,7 @@ def test_solver_should_not_update_same_version_packages_if_installed_has_no_sour
...
@@ -3410,7 +3410,7 @@ def test_solver_should_not_update_same_version_packages_if_installed_has_no_sour
def
test_solver_should_use_the_python_constraint_from_the_environment_if_available
(
def
test_solver_should_use_the_python_constraint_from_the_environment_if_available
(
solver
:
Solver
,
repo
:
Repository
,
package
:
ProjectPackage
solver
:
Solver
,
repo
:
Repository
,
package
:
ProjectPackage
):
)
->
None
:
set_package_python_versions
(
solver
.
provider
,
"~2.7 || ^3.5"
)
set_package_python_versions
(
solver
.
provider
,
"~2.7 || ^3.5"
)
package
.
add_dependency
(
Factory
.
create_dependency
(
"A"
,
"^1.0"
))
package
.
add_dependency
(
Factory
.
create_dependency
(
"A"
,
"^1.0"
))
...
...
tests/repositories/test_installed_repository.py
View file @
99f106c5
...
@@ -51,10 +51,10 @@ INSTALLED_RESULTS = [
...
@@ -51,10 +51,10 @@ INSTALLED_RESULTS = [
class
MockEnv
(
BaseMockEnv
):
class
MockEnv
(
BaseMockEnv
):
@property
@property
def
paths
(
self
)
->
dict
[
str
,
Path
]:
def
paths
(
self
)
->
dict
[
str
,
str
]:
return
{
return
{
"purelib"
:
SITE_PURELIB
,
"purelib"
:
SITE_PURELIB
.
as_posix
()
,
"platlib"
:
SITE_PLATLIB
,
"platlib"
:
SITE_PLATLIB
.
as_posix
()
,
}
}
@property
@property
...
@@ -96,7 +96,7 @@ def get_package_from_repository(
...
@@ -96,7 +96,7 @@ def get_package_from_repository(
return
None
return
None
def
test_load_successful
(
repository
:
InstalledRepository
):
def
test_load_successful
(
repository
:
InstalledRepository
)
->
None
:
assert
len
(
repository
.
packages
)
==
len
(
INSTALLED_RESULTS
)
assert
len
(
repository
.
packages
)
==
len
(
INSTALLED_RESULTS
)
...
@@ -119,12 +119,12 @@ def test_load_successful_with_invalid_distribution(
...
@@ -119,12 +119,12 @@ def test_load_successful_with_invalid_distribution(
assert
str
(
invalid_dist_info
)
in
message
assert
str
(
invalid_dist_info
)
in
message
def
test_load_ensure_isolation
(
repository
:
InstalledRepository
):
def
test_load_ensure_isolation
(
repository
:
InstalledRepository
)
->
None
:
package
=
get_package_from_repository
(
"attrs"
,
repository
)
package
=
get_package_from_repository
(
"attrs"
,
repository
)
assert
package
is
None
assert
package
is
None
def
test_load_standard_package
(
repository
:
InstalledRepository
):
def
test_load_standard_package
(
repository
:
InstalledRepository
)
->
None
:
cleo
=
get_package_from_repository
(
"cleo"
,
repository
)
cleo
=
get_package_from_repository
(
"cleo"
,
repository
)
assert
cleo
is
not
None
assert
cleo
is
not
None
assert
cleo
.
name
==
"cleo"
assert
cleo
.
name
==
"cleo"
...
@@ -139,7 +139,7 @@ def test_load_standard_package(repository: InstalledRepository):
...
@@ -139,7 +139,7 @@ def test_load_standard_package(repository: InstalledRepository):
assert
foo
.
version
.
text
==
"0.1.0"
assert
foo
.
version
.
text
==
"0.1.0"
def
test_load_git_package
(
repository
:
InstalledRepository
):
def
test_load_git_package
(
repository
:
InstalledRepository
)
->
None
:
pendulum
=
get_package_from_repository
(
"pendulum"
,
repository
)
pendulum
=
get_package_from_repository
(
"pendulum"
,
repository
)
assert
pendulum
is
not
None
assert
pendulum
is
not
None
assert
pendulum
.
name
==
"pendulum"
assert
pendulum
.
name
==
"pendulum"
...
@@ -153,7 +153,7 @@ def test_load_git_package(repository: InstalledRepository):
...
@@ -153,7 +153,7 @@ def test_load_git_package(repository: InstalledRepository):
assert
pendulum
.
source_reference
==
"bb058f6b78b2d28ef5d9a5e759cfa179a1a713d6"
assert
pendulum
.
source_reference
==
"bb058f6b78b2d28ef5d9a5e759cfa179a1a713d6"
def
test_load_git_package_pth
(
repository
:
InstalledRepository
):
def
test_load_git_package_pth
(
repository
:
InstalledRepository
)
->
None
:
bender
=
get_package_from_repository
(
"bender"
,
repository
)
bender
=
get_package_from_repository
(
"bender"
,
repository
)
assert
bender
is
not
None
assert
bender
is
not
None
assert
bender
.
name
==
"bender"
assert
bender
.
name
==
"bender"
...
@@ -161,14 +161,14 @@ def test_load_git_package_pth(repository: InstalledRepository):
...
@@ -161,14 +161,14 @@ def test_load_git_package_pth(repository: InstalledRepository):
assert
bender
.
source_type
==
"git"
assert
bender
.
source_type
==
"git"
def
test_load_platlib_package
(
repository
:
InstalledRepository
):
def
test_load_platlib_package
(
repository
:
InstalledRepository
)
->
None
:
lib64
=
get_package_from_repository
(
"lib64"
,
repository
)
lib64
=
get_package_from_repository
(
"lib64"
,
repository
)
assert
lib64
is
not
None
assert
lib64
is
not
None
assert
lib64
.
name
==
"lib64"
assert
lib64
.
name
==
"lib64"
assert
lib64
.
version
.
text
==
"2.3.4"
assert
lib64
.
version
.
text
==
"2.3.4"
def
test_load_editable_package
(
repository
:
InstalledRepository
):
def
test_load_editable_package
(
repository
:
InstalledRepository
)
->
None
:
# test editable package with text .pth file
# test editable package with text .pth file
editable
=
get_package_from_repository
(
"editable"
,
repository
)
editable
=
get_package_from_repository
(
"editable"
,
repository
)
assert
editable
is
not
None
assert
editable
is
not
None
...
@@ -181,7 +181,7 @@ def test_load_editable_package(repository: InstalledRepository):
...
@@ -181,7 +181,7 @@ def test_load_editable_package(repository: InstalledRepository):
)
)
def
test_load_editable_with_import_package
(
repository
:
InstalledRepository
):
def
test_load_editable_with_import_package
(
repository
:
InstalledRepository
)
->
None
:
# test editable package with executable .pth file
# test editable package with executable .pth file
editable
=
get_package_from_repository
(
"editable-with-import"
,
repository
)
editable
=
get_package_from_repository
(
"editable-with-import"
,
repository
)
assert
editable
is
not
None
assert
editable
is
not
None
...
@@ -191,7 +191,7 @@ def test_load_editable_with_import_package(repository: InstalledRepository):
...
@@ -191,7 +191,7 @@ def test_load_editable_with_import_package(repository: InstalledRepository):
assert
editable
.
source_url
is
None
assert
editable
.
source_url
is
None
def
test_load_standard_package_with_pth_file
(
repository
:
InstalledRepository
):
def
test_load_standard_package_with_pth_file
(
repository
:
InstalledRepository
)
->
None
:
# test standard packages with .pth file is not treated as editable
# test standard packages with .pth file is not treated as editable
standard
=
get_package_from_repository
(
"standard"
,
repository
)
standard
=
get_package_from_repository
(
"standard"
,
repository
)
assert
standard
is
not
None
assert
standard
is
not
None
...
@@ -201,7 +201,7 @@ def test_load_standard_package_with_pth_file(repository: InstalledRepository):
...
@@ -201,7 +201,7 @@ def test_load_standard_package_with_pth_file(repository: InstalledRepository):
assert
standard
.
source_url
is
None
assert
standard
.
source_url
is
None
def
test_load_pep_610_compliant_git_packages
(
repository
:
InstalledRepository
):
def
test_load_pep_610_compliant_git_packages
(
repository
:
InstalledRepository
)
->
None
:
package
=
get_package_from_repository
(
"git-pep-610"
,
repository
)
package
=
get_package_from_repository
(
"git-pep-610"
,
repository
)
assert
package
is
not
None
assert
package
is
not
None
...
@@ -215,7 +215,7 @@ def test_load_pep_610_compliant_git_packages(repository: InstalledRepository):
...
@@ -215,7 +215,7 @@ def test_load_pep_610_compliant_git_packages(repository: InstalledRepository):
def
test_load_pep_610_compliant_git_packages_no_requested_version
(
def
test_load_pep_610_compliant_git_packages_no_requested_version
(
repository
:
InstalledRepository
,
repository
:
InstalledRepository
,
):
)
->
None
:
package
=
get_package_from_repository
(
package
=
get_package_from_repository
(
"git-pep-610-no-requested-version"
,
repository
"git-pep-610-no-requested-version"
,
repository
)
)
...
@@ -234,7 +234,7 @@ def test_load_pep_610_compliant_git_packages_no_requested_version(
...
@@ -234,7 +234,7 @@ def test_load_pep_610_compliant_git_packages_no_requested_version(
def
test_load_pep_610_compliant_git_packages_with_subdirectory
(
def
test_load_pep_610_compliant_git_packages_with_subdirectory
(
repository
:
InstalledRepository
,
repository
:
InstalledRepository
,
):
)
->
None
:
package
=
get_package_from_repository
(
"git-pep-610-subdirectory"
,
repository
)
package
=
get_package_from_repository
(
"git-pep-610-subdirectory"
,
repository
)
assert
package
is
not
None
assert
package
is
not
None
assert
package
.
name
==
"git-pep-610-subdirectory"
assert
package
.
name
==
"git-pep-610-subdirectory"
...
@@ -246,7 +246,7 @@ def test_load_pep_610_compliant_git_packages_with_subdirectory(
...
@@ -246,7 +246,7 @@ def test_load_pep_610_compliant_git_packages_with_subdirectory(
assert
package
.
source_subdirectory
==
"subdir"
assert
package
.
source_subdirectory
==
"subdir"
def
test_load_pep_610_compliant_url_packages
(
repository
:
InstalledRepository
):
def
test_load_pep_610_compliant_url_packages
(
repository
:
InstalledRepository
)
->
None
:
package
=
get_package_from_repository
(
"url-pep-610"
,
repository
)
package
=
get_package_from_repository
(
"url-pep-610"
,
repository
)
assert
package
is
not
None
assert
package
is
not
None
...
@@ -259,7 +259,7 @@ def test_load_pep_610_compliant_url_packages(repository: InstalledRepository):
...
@@ -259,7 +259,7 @@ def test_load_pep_610_compliant_url_packages(repository: InstalledRepository):
)
)
def
test_load_pep_610_compliant_file_packages
(
repository
:
InstalledRepository
):
def
test_load_pep_610_compliant_file_packages
(
repository
:
InstalledRepository
)
->
None
:
package
=
get_package_from_repository
(
"file-pep-610"
,
repository
)
package
=
get_package_from_repository
(
"file-pep-610"
,
repository
)
assert
package
is
not
None
assert
package
is
not
None
...
@@ -269,7 +269,9 @@ def test_load_pep_610_compliant_file_packages(repository: InstalledRepository):
...
@@ -269,7 +269,9 @@ def test_load_pep_610_compliant_file_packages(repository: InstalledRepository):
assert
package
.
source_url
==
"/path/to/distributions/file-pep-610-1.2.3.tar.gz"
assert
package
.
source_url
==
"/path/to/distributions/file-pep-610-1.2.3.tar.gz"
def
test_load_pep_610_compliant_directory_packages
(
repository
:
InstalledRepository
):
def
test_load_pep_610_compliant_directory_packages
(
repository
:
InstalledRepository
,
)
->
None
:
package
=
get_package_from_repository
(
"directory-pep-610"
,
repository
)
package
=
get_package_from_repository
(
"directory-pep-610"
,
repository
)
assert
package
is
not
None
assert
package
is
not
None
...
@@ -282,7 +284,7 @@ def test_load_pep_610_compliant_directory_packages(repository: InstalledReposito
...
@@ -282,7 +284,7 @@ def test_load_pep_610_compliant_directory_packages(repository: InstalledReposito
def
test_load_pep_610_compliant_editable_directory_packages
(
def
test_load_pep_610_compliant_editable_directory_packages
(
repository
:
InstalledRepository
,
repository
:
InstalledRepository
,
):
)
->
None
:
package
=
get_package_from_repository
(
"editable-directory-pep-610"
,
repository
)
package
=
get_package_from_repository
(
"editable-directory-pep-610"
,
repository
)
assert
package
is
not
None
assert
package
is
not
None
...
...
tests/utils/test_authenticator.py
View file @
99f106c5
This diff is collapsed.
Click to expand it.
tests/utils/test_password_manager.py
View file @
99f106c5
...
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
...
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
def
test_set_http_password
(
def
test_set_http_password
(
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
):
)
->
None
:
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
assert
manager
.
keyring
.
is_available
()
assert
manager
.
keyring
.
is_available
()
...
@@ -35,13 +35,14 @@ def test_set_http_password(
...
@@ -35,13 +35,14 @@ def test_set_http_password(
def
test_get_http_auth
(
def
test_get_http_auth
(
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
):
)
->
None
:
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"bar"
,
"baz"
)
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"bar"
,
"baz"
)
config
.
auth_config_source
.
add_property
(
"http-basic.foo"
,
{
"username"
:
"bar"
})
config
.
auth_config_source
.
add_property
(
"http-basic.foo"
,
{
"username"
:
"bar"
})
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
assert
manager
.
keyring
.
is_available
()
assert
manager
.
keyring
.
is_available
()
auth
=
manager
.
get_http_auth
(
"foo"
)
auth
=
manager
.
get_http_auth
(
"foo"
)
assert
auth
is
not
None
assert
auth
[
"username"
]
==
"bar"
assert
auth
[
"username"
]
==
"bar"
assert
auth
[
"password"
]
==
"baz"
assert
auth
[
"password"
]
==
"baz"
...
@@ -49,7 +50,7 @@ def test_get_http_auth(
...
@@ -49,7 +50,7 @@ def test_get_http_auth(
def
test_delete_http_password
(
def
test_delete_http_password
(
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
):
)
->
None
:
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"bar"
,
"baz"
)
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"bar"
,
"baz"
)
config
.
auth_config_source
.
add_property
(
"http-basic.foo"
,
{
"username"
:
"bar"
})
config
.
auth_config_source
.
add_property
(
"http-basic.foo"
,
{
"username"
:
"bar"
})
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
...
@@ -63,7 +64,7 @@ def test_delete_http_password(
...
@@ -63,7 +64,7 @@ def test_delete_http_password(
def
test_set_pypi_token
(
def
test_set_pypi_token
(
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
):
)
->
None
:
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
assert
manager
.
keyring
.
is_available
()
assert
manager
.
keyring
.
is_available
()
...
@@ -76,7 +77,7 @@ def test_set_pypi_token(
...
@@ -76,7 +77,7 @@ def test_set_pypi_token(
def
test_get_pypi_token
(
def
test_get_pypi_token
(
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
):
)
->
None
:
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"__token__"
,
"baz"
)
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"__token__"
,
"baz"
)
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
...
@@ -86,7 +87,7 @@ def test_get_pypi_token(
...
@@ -86,7 +87,7 @@ def test_get_pypi_token(
def
test_delete_pypi_token
(
def
test_delete_pypi_token
(
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
):
)
->
None
:
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"__token__"
,
"baz"
)
dummy_keyring
.
set_password
(
"poetry-repository-foo"
,
"__token__"
,
"baz"
)
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
...
@@ -98,7 +99,7 @@ def test_delete_pypi_token(
...
@@ -98,7 +99,7 @@ def test_delete_pypi_token(
def
test_set_http_password_with_unavailable_backend
(
def
test_set_http_password_with_unavailable_backend
(
config
:
Config
,
with_fail_keyring
:
None
config
:
Config
,
with_fail_keyring
:
None
):
)
->
None
:
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
assert
not
manager
.
keyring
.
is_available
()
assert
not
manager
.
keyring
.
is_available
()
...
@@ -111,7 +112,7 @@ def test_set_http_password_with_unavailable_backend(
...
@@ -111,7 +112,7 @@ def test_set_http_password_with_unavailable_backend(
def
test_get_http_auth_with_unavailable_backend
(
def
test_get_http_auth_with_unavailable_backend
(
config
:
Config
,
with_fail_keyring
:
None
config
:
Config
,
with_fail_keyring
:
None
):
)
->
None
:
config
.
auth_config_source
.
add_property
(
config
.
auth_config_source
.
add_property
(
"http-basic.foo"
,
{
"username"
:
"bar"
,
"password"
:
"baz"
}
"http-basic.foo"
,
{
"username"
:
"bar"
,
"password"
:
"baz"
}
)
)
...
@@ -119,6 +120,7 @@ def test_get_http_auth_with_unavailable_backend(
...
@@ -119,6 +120,7 @@ def test_get_http_auth_with_unavailable_backend(
assert
not
manager
.
keyring
.
is_available
()
assert
not
manager
.
keyring
.
is_available
()
auth
=
manager
.
get_http_auth
(
"foo"
)
auth
=
manager
.
get_http_auth
(
"foo"
)
assert
auth
is
not
None
assert
auth
[
"username"
]
==
"bar"
assert
auth
[
"username"
]
==
"bar"
assert
auth
[
"password"
]
==
"baz"
assert
auth
[
"password"
]
==
"baz"
...
@@ -126,7 +128,7 @@ def test_get_http_auth_with_unavailable_backend(
...
@@ -126,7 +128,7 @@ def test_get_http_auth_with_unavailable_backend(
def
test_delete_http_password_with_unavailable_backend
(
def
test_delete_http_password_with_unavailable_backend
(
config
:
Config
,
with_fail_keyring
:
None
config
:
Config
,
with_fail_keyring
:
None
):
)
->
None
:
config
.
auth_config_source
.
add_property
(
config
.
auth_config_source
.
add_property
(
"http-basic.foo"
,
{
"username"
:
"bar"
,
"password"
:
"baz"
}
"http-basic.foo"
,
{
"username"
:
"bar"
,
"password"
:
"baz"
}
)
)
...
@@ -140,7 +142,7 @@ def test_delete_http_password_with_unavailable_backend(
...
@@ -140,7 +142,7 @@ def test_delete_http_password_with_unavailable_backend(
def
test_set_pypi_token_with_unavailable_backend
(
def
test_set_pypi_token_with_unavailable_backend
(
config
:
Config
,
with_fail_keyring
:
None
config
:
Config
,
with_fail_keyring
:
None
):
)
->
None
:
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
assert
not
manager
.
keyring
.
is_available
()
assert
not
manager
.
keyring
.
is_available
()
...
@@ -151,7 +153,7 @@ def test_set_pypi_token_with_unavailable_backend(
...
@@ -151,7 +153,7 @@ def test_set_pypi_token_with_unavailable_backend(
def
test_get_pypi_token_with_unavailable_backend
(
def
test_get_pypi_token_with_unavailable_backend
(
config
:
Config
,
with_fail_keyring
:
None
config
:
Config
,
with_fail_keyring
:
None
):
)
->
None
:
config
.
auth_config_source
.
add_property
(
"pypi-token.foo"
,
"baz"
)
config
.
auth_config_source
.
add_property
(
"pypi-token.foo"
,
"baz"
)
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
...
@@ -161,7 +163,7 @@ def test_get_pypi_token_with_unavailable_backend(
...
@@ -161,7 +163,7 @@ def test_get_pypi_token_with_unavailable_backend(
def
test_delete_pypi_token_with_unavailable_backend
(
def
test_delete_pypi_token_with_unavailable_backend
(
config
:
Config
,
with_fail_keyring
:
None
config
:
Config
,
with_fail_keyring
:
None
):
)
->
None
:
config
.
auth_config_source
.
add_property
(
"pypi-token.foo"
,
"baz"
)
config
.
auth_config_source
.
add_property
(
"pypi-token.foo"
,
"baz"
)
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
...
@@ -173,7 +175,7 @@ def test_delete_pypi_token_with_unavailable_backend(
...
@@ -173,7 +175,7 @@ def test_delete_pypi_token_with_unavailable_backend(
def
test_keyring_raises_errors_on_keyring_errors
(
def
test_keyring_raises_errors_on_keyring_errors
(
mocker
:
MockerFixture
,
with_fail_keyring
:
None
mocker
:
MockerFixture
,
with_fail_keyring
:
None
):
)
->
None
:
mocker
.
patch
(
"poetry.utils.password_manager.PoetryKeyring._check"
)
mocker
.
patch
(
"poetry.utils.password_manager.PoetryKeyring._check"
)
key_ring
=
PoetryKeyring
(
"poetry"
)
key_ring
=
PoetryKeyring
(
"poetry"
)
...
@@ -189,7 +191,7 @@ def test_keyring_raises_errors_on_keyring_errors(
...
@@ -189,7 +191,7 @@ def test_keyring_raises_errors_on_keyring_errors(
def
test_keyring_with_chainer_backend_and_fail_keyring_should_be_unavailable
(
def
test_keyring_with_chainer_backend_and_fail_keyring_should_be_unavailable
(
with_chained_fail_keyring
:
None
,
with_chained_fail_keyring
:
None
,
):
)
->
None
:
key_ring
=
PoetryKeyring
(
"poetry"
)
key_ring
=
PoetryKeyring
(
"poetry"
)
assert
not
key_ring
.
is_available
()
assert
not
key_ring
.
is_available
()
...
@@ -197,7 +199,7 @@ def test_keyring_with_chainer_backend_and_fail_keyring_should_be_unavailable(
...
@@ -197,7 +199,7 @@ def test_keyring_with_chainer_backend_and_fail_keyring_should_be_unavailable(
def
test_keyring_with_chainer_backend_and_null_keyring_should_be_unavailable
(
def
test_keyring_with_chainer_backend_and_null_keyring_should_be_unavailable
(
with_chained_null_keyring
:
None
,
with_chained_null_keyring
:
None
,
):
)
->
None
:
key_ring
=
PoetryKeyring
(
"poetry"
)
key_ring
=
PoetryKeyring
(
"poetry"
)
assert
not
key_ring
.
is_available
()
assert
not
key_ring
.
is_available
()
...
@@ -205,7 +207,7 @@ def test_keyring_with_chainer_backend_and_null_keyring_should_be_unavailable(
...
@@ -205,7 +207,7 @@ def test_keyring_with_chainer_backend_and_null_keyring_should_be_unavailable(
def
test_null_keyring_should_be_unavailable
(
def
test_null_keyring_should_be_unavailable
(
with_null_keyring
:
None
,
with_null_keyring
:
None
,
):
)
->
None
:
key_ring
=
PoetryKeyring
(
"poetry"
)
key_ring
=
PoetryKeyring
(
"poetry"
)
assert
not
key_ring
.
is_available
()
assert
not
key_ring
.
is_available
()
...
@@ -213,7 +215,7 @@ def test_null_keyring_should_be_unavailable(
...
@@ -213,7 +215,7 @@ def test_null_keyring_should_be_unavailable(
def
test_fail_keyring_should_be_unavailable
(
def
test_fail_keyring_should_be_unavailable
(
with_fail_keyring
:
None
,
with_fail_keyring
:
None
,
):
)
->
None
:
key_ring
=
PoetryKeyring
(
"poetry"
)
key_ring
=
PoetryKeyring
(
"poetry"
)
assert
not
key_ring
.
is_available
()
assert
not
key_ring
.
is_available
()
...
@@ -221,13 +223,14 @@ def test_fail_keyring_should_be_unavailable(
...
@@ -221,13 +223,14 @@ def test_fail_keyring_should_be_unavailable(
def
test_get_http_auth_from_environment_variables
(
def
test_get_http_auth_from_environment_variables
(
environ
:
None
,
config
:
Config
,
with_simple_keyring
:
None
environ
:
None
,
config
:
Config
,
with_simple_keyring
:
None
):
)
->
None
:
os
.
environ
[
"POETRY_HTTP_BASIC_FOO_USERNAME"
]
=
"bar"
os
.
environ
[
"POETRY_HTTP_BASIC_FOO_USERNAME"
]
=
"bar"
os
.
environ
[
"POETRY_HTTP_BASIC_FOO_PASSWORD"
]
=
"baz"
os
.
environ
[
"POETRY_HTTP_BASIC_FOO_PASSWORD"
]
=
"baz"
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
auth
=
manager
.
get_http_auth
(
"foo"
)
auth
=
manager
.
get_http_auth
(
"foo"
)
assert
auth
is
not
None
assert
auth
[
"username"
]
==
"bar"
assert
auth
[
"username"
]
==
"bar"
assert
auth
[
"password"
]
==
"baz"
assert
auth
[
"password"
]
==
"baz"
...
@@ -238,7 +241,7 @@ def test_get_pypi_token_with_env_var_positive(
...
@@ -238,7 +241,7 @@ def test_get_pypi_token_with_env_var_positive(
config
:
Config
,
config
:
Config
,
with_simple_keyring
:
None
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
,
dummy_keyring
:
DummyBackend
,
):
)
->
None
:
sample_token
=
"sampletoken-1234"
sample_token
=
"sampletoken-1234"
repo_name
=
"foo"
repo_name
=
"foo"
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
...
@@ -252,7 +255,7 @@ def test_get_pypi_token_with_env_var_positive(
...
@@ -252,7 +255,7 @@ def test_get_pypi_token_with_env_var_positive(
def
test_get_pypi_token_with_env_var_not_available
(
def
test_get_pypi_token_with_env_var_not_available
(
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
config
:
Config
,
with_simple_keyring
:
None
,
dummy_keyring
:
DummyBackend
):
)
->
None
:
repo_name
=
"foo"
repo_name
=
"foo"
manager
=
PasswordManager
(
config
)
manager
=
PasswordManager
(
config
)
...
...
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