Commit 7aefbd69 by Randy Döring Committed by GitHub

Use flake8 simplify (#4798)

* Fix SIM102: Use a single if-statement instead of nested if-statements

* Fix SIM105: Use 'contextlib.suppress(...)' instead of try-except-pass

* Fix SIM110: Use 'return any(...)'

* Fix SIM113: Use enumerate instead of manually incrementing a counter

* Fix SIM114: Combine conditions via a logical or to prevent duplicating code

* Fix SIM211: Use 'not a' instead of 'False if a else True'

* Fix SIM300: Use 'age == 42' instead of '42 == age' (Yoda-conditions)

* Fix SIM119: Use dataclasses for data containers

* Ignore "SIM106: Handle error-cases first" for now
parent 5c328a36
...@@ -10,6 +10,8 @@ extend-ignore = ...@@ -10,6 +10,8 @@ extend-ignore =
E501, E501,
# E203: Whitespace before ':' (pycqa/pycodestyle#373) # E203: Whitespace before ':' (pycqa/pycodestyle#373)
E203, E203,
# SIM106: Handle error-cases first
SIM106,
per-file-ignores = per-file-ignores =
# F401: Module imported by unused (non-implicit modules) # F401: Module imported by unused (non-implicit modules)
# TC002: Move third-party import '...' into a type-checking block # TC002: Move third-party import '...' into a type-checking block
......
...@@ -36,6 +36,7 @@ repos: ...@@ -36,6 +36,7 @@ repos:
- flake8-comprehensions==3.7.0 - flake8-comprehensions==3.7.0
- flake8-no-pep420==1.2.0 - flake8-no-pep420==1.2.0
- flake8-quotes==3.3.1 - flake8-quotes==3.3.1
- flake8-simplify==0.14.2
- flake8-tidy-imports==4.5.0 - flake8-tidy-imports==4.5.0
- flake8-type-checking==1.1.0 - flake8-type-checking==1.1.0
- flake8-typing-imports==1.11.0 - flake8-typing-imports==1.11.0
......
...@@ -125,8 +125,8 @@ def is_decorated(): ...@@ -125,8 +125,8 @@ def is_decorated():
if platform.system().lower() == "windows": if platform.system().lower() == "windows":
return ( return (
os.getenv("ANSICON") is not None os.getenv("ANSICON") is not None
or "ON" == os.getenv("ConEmuANSI") or os.getenv("ConEmuANSI") == "ON"
or "xterm" == os.getenv("Term") or os.getenv("Term") == "xterm"
) )
if not hasattr(sys.stdout, "fileno"): if not hasattr(sys.stdout, "fileno"):
......
...@@ -96,8 +96,8 @@ def is_decorated(): ...@@ -96,8 +96,8 @@ def is_decorated():
if WINDOWS: if WINDOWS:
return ( return (
os.getenv("ANSICON") is not None os.getenv("ANSICON") is not None
or "ON" == os.getenv("ConEmuANSI") or os.getenv("ConEmuANSI") == "ON"
or "xterm" == os.getenv("Term") or os.getenv("Term") == "xterm"
) )
if not hasattr(sys.stdout, "fileno"): if not hasattr(sys.stdout, "fileno"):
......
import logging import logging
import re import re
from contextlib import suppress
from importlib import import_module from importlib import import_module
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
...@@ -195,10 +196,8 @@ class Application(BaseApplication): ...@@ -195,10 +196,8 @@ class Application(BaseApplication):
# We need to check if the command being run # We need to check if the command being run
# is the "run" command. # is the "run" command.
definition = self.definition definition = self.definition
try: with suppress(CleoException):
io.input.bind(definition) io.input.bind(definition)
except CleoException:
pass
name = io.input.first_argument name = io.input.first_argument
if name == "run": if name == "run":
...@@ -218,10 +217,8 @@ class Application(BaseApplication): ...@@ -218,10 +217,8 @@ class Application(BaseApplication):
for shortcut in shortcuts: for shortcut in shortcuts:
run_input.add_parameter_option("-" + shortcut.lstrip("-")) run_input.add_parameter_option("-" + shortcut.lstrip("-"))
try: with suppress(CleoException):
run_input.bind(definition) run_input.bind(definition)
except CleoException:
pass
for option_name, value in input.options.items(): for option_name, value in input.options.items():
if value: if value:
......
import sys import sys
from contextlib import suppress
from cleo.helpers import argument from cleo.helpers import argument
from cleo.helpers import option from cleo.helpers import option
...@@ -44,13 +46,11 @@ class NewCommand(Command): ...@@ -44,13 +46,11 @@ class NewCommand(Command):
if not name: if not name:
name = path.name name = path.name
if path.exists(): if path.exists() and list(path.glob("*")):
if list(path.glob("*")): # Directory is not empty. Aborting.
# Directory is not empty. Aborting. raise RuntimeError(
raise RuntimeError( "Destination <fg=yellow>{}</> " "exists and is not empty".format(path)
"Destination <fg=yellow>{}</> " )
"exists and is not empty".format(path)
)
readme_format = self.option("readme") or "md" readme_format = self.option("readme") or "md"
...@@ -78,10 +78,8 @@ class NewCommand(Command): ...@@ -78,10 +78,8 @@ class NewCommand(Command):
path = path.resolve() path = path.resolve()
try: with suppress(ValueError):
path = path.relative_to(Path.cwd()) path = path.relative_to(Path.cwd())
except ValueError:
pass
self.line( self.line(
"Created package <info>{}</> in <fg=blue>{}</>".format( "Created package <info>{}</> in <fg=blue>{}</>".format(
......
...@@ -48,14 +48,13 @@ the config command. ...@@ -48,14 +48,13 @@ the config command.
# Building package first, if told # Building package first, if told
if self.option("build"): if self.option("build"):
if publisher.files: if publisher.files and not self.confirm(
if not self.confirm( "There are <info>{}</info> files ready for publishing. "
"There are <info>{}</info> files ready for publishing. " "Build anyway?".format(len(publisher.files))
"Build anyway?".format(len(publisher.files)) ):
): self.line_error("<error>Aborted!</error>")
self.line_error("<error>Aborted!</error>")
return 1
return 1
self.call("build") self.call("build")
......
...@@ -359,11 +359,9 @@ lists all packages available.""" ...@@ -359,11 +359,9 @@ lists all packages available."""
dependencies = package.requires dependencies = package.requires
dependencies = sorted(dependencies, key=lambda x: x.name) dependencies = sorted(dependencies, key=lambda x: x.name)
tree_bar = "├" tree_bar = "├"
j = 0
total = len(dependencies) total = len(dependencies)
for dependency in dependencies: for i, dependency in enumerate(dependencies, 1):
j += 1 if i == total:
if j == total:
tree_bar = "└" tree_bar = "└"
level = 1 level = 1
...@@ -403,10 +401,8 @@ lists all packages available.""" ...@@ -403,10 +401,8 @@ lists all packages available."""
dependencies = sorted(dependencies, key=lambda x: x.name) dependencies = sorted(dependencies, key=lambda x: x.name)
tree_bar = previous_tree_bar + " ├" tree_bar = previous_tree_bar + " ├"
i = 0
total = len(dependencies) total = len(dependencies)
for dependency in dependencies: for i, dependency in enumerate(dependencies, 1):
i += 1
current_tree = packages_in_tree current_tree = packages_in_tree
if i == total: if i == total:
tree_bar = previous_tree_bar + " └" tree_bar = previous_tree_bar + " └"
......
...@@ -60,9 +60,8 @@ class Factory(BaseFactory): ...@@ -60,9 +60,8 @@ class Factory(BaseFactory):
for source in base_poetry.pyproject.poetry_config.get("source", []): for source in base_poetry.pyproject.poetry_config.get("source", []):
name = source.get("name") name = source.get("name")
url = source.get("url") url = source.get("url")
if name and url: if name and url and name not in existing_repositories:
if name not in existing_repositories: repositories[name] = {"url": url}
repositories[name] = {"url": url}
config.merge({"repositories": repositories}) config.merge({"repositories": repositories})
......
...@@ -211,15 +211,16 @@ class Executor: ...@@ -211,15 +211,16 @@ class Executor:
def _execute_operation(self, operation: "OperationTypes") -> None: def _execute_operation(self, operation: "OperationTypes") -> None:
try: try:
if self.supports_fancy_output(): if self.supports_fancy_output():
if id(operation) not in self._sections: if id(operation) not in self._sections and self._should_write_operation(
if self._should_write_operation(operation): operation
with self._lock: ):
self._sections[id(operation)] = self._io.section() with self._lock:
self._sections[id(operation)].write_line( self._sections[id(operation)] = self._io.section()
" <fg=blue;options=bold>•</> {message}: <fg=blue>Pending...</>".format( self._sections[id(operation)].write_line(
message=self.get_operation_message(operation), " <fg=blue;options=bold>•</> {message}: <fg=blue>Pending...</>".format(
), message=self.get_operation_message(operation),
) ),
)
else: else:
if self._should_write_operation(operation): if self._should_write_operation(operation):
if not operation.skipped: if not operation.skipped:
......
...@@ -569,9 +569,8 @@ class Installer: ...@@ -569,9 +569,8 @@ class Installer:
# If a package is optional and not requested # If a package is optional and not requested
# in any extra we skip it # in any extra we skip it
if package.optional: if package.optional and package.name not in extra_packages:
if package.name not in extra_packages: op.skip("Not required")
op.skip("Not required")
def _get_extra_packages(self, repo: Repository) -> List[str]: def _get_extra_packages(self, repo: Repository) -> List[str]:
""" """
......
...@@ -66,12 +66,14 @@ class PipInstaller(BaseInstaller): ...@@ -66,12 +66,14 @@ class PipInstaller(BaseInstaller):
index_url = repository.authenticated_url index_url = repository.authenticated_url
args += ["--index-url", index_url] args += ["--index-url", index_url]
if self._pool.has_default(): if (
if repository.name != self._pool.repositories[0].name: self._pool.has_default()
args += [ and repository.name != self._pool.repositories[0].name
"--extra-index-url", ):
self._pool.repositories[0].authenticated_url, args += [
] "--extra-index-url",
self._pool.repositories[0].authenticated_url,
]
if update: if update:
args.append("-U") args.append("-U")
......
...@@ -507,12 +507,14 @@ class Provider: ...@@ -507,12 +507,14 @@ class Provider:
if self._env and not dep.marker.validate(self._env.marker_env): if self._env and not dep.marker.validate(self._env.marker_env):
continue continue
if not package.is_root(): if not package.is_root() and (
if (dep.is_optional() and dep.name not in optional_dependencies) or ( (dep.is_optional() and dep.name not in optional_dependencies)
or (
dep.in_extras dep.in_extras
and not set(dep.in_extras).intersection(package.dependency.extras) and not set(dep.in_extras).intersection(package.dependency.extras)
): )
continue ):
continue
_dependencies.append(dep) _dependencies.append(dep)
......
...@@ -42,14 +42,13 @@ class Transaction: ...@@ -42,14 +42,13 @@ class Transaction:
if result_package.name == installed_package.name: if result_package.name == installed_package.name:
installed = True installed = True
if result_package.version != installed_package.version: if result_package.version != installed_package.version or (
operations.append( (
Update(installed_package, result_package, priority=priority) installed_package.source_type
or result_package.source_type != "legacy"
) )
elif ( and not result_package.is_same_package_as(installed_package)
installed_package.source_type ):
or result_package.source_type != "legacy"
) and not result_package.is_same_package_as(installed_package):
operations.append( operations.append(
Update(installed_package, result_package, priority=priority) Update(installed_package, result_package, priority=priority)
) )
......
...@@ -237,14 +237,13 @@ class LegacyRepository(PyPiRepository): ...@@ -237,14 +237,13 @@ class LegacyRepository(PyPiRepository):
constraint = parse_constraint(constraint) constraint = parse_constraint(constraint)
allow_prereleases = dependency.allows_prereleases() allow_prereleases = dependency.allows_prereleases()
if isinstance(constraint, VersionRange): if isinstance(constraint, VersionRange) and (
if ( constraint.max is not None
constraint.max is not None and constraint.max.is_unstable()
and constraint.max.is_unstable() or constraint.min is not None
or constraint.min is not None and constraint.min.is_unstable()
and constraint.min.is_unstable() ):
): allow_prereleases = True
allow_prereleases = True
key = dependency.name key = dependency.name
if not constraint.is_any(): if not constraint.is_any():
......
from contextlib import suppress
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Dict from typing import Dict
from typing import List from typing import List
...@@ -135,10 +136,8 @@ class Pool(BaseRepository): ...@@ -135,10 +136,8 @@ class Pool(BaseRepository):
raise ValueError(f'Repository "{repository}" does not exist.') raise ValueError(f'Repository "{repository}" does not exist.')
if repository is not None and not self._ignore_repository_names: if repository is not None and not self._ignore_repository_names:
try: with suppress(PackageNotFound):
return self.repository(repository).package(name, version, extras=extras) return self.repository(repository).package(name, version, extras=extras)
except PackageNotFound:
pass
else: else:
for repo in self._repositories: for repo in self._repositories:
try: try:
......
...@@ -97,14 +97,13 @@ class PyPiRepository(RemoteRepository): ...@@ -97,14 +97,13 @@ class PyPiRepository(RemoteRepository):
constraint = parse_constraint(constraint) constraint = parse_constraint(constraint)
allow_prereleases = dependency.allows_prereleases() allow_prereleases = dependency.allows_prereleases()
if isinstance(constraint, VersionRange): if isinstance(constraint, VersionRange) and (
if ( constraint.max is not None
constraint.max is not None and constraint.max.is_unstable()
and constraint.max.is_unstable() or constraint.min is not None
or constraint.min is not None and constraint.min.is_unstable()
and constraint.min.is_unstable() ):
): allow_prereleases = True
allow_prereleases = True
try: try:
info = self.get_package_info(dependency.name) info = self.get_package_info(dependency.name)
......
...@@ -52,14 +52,13 @@ class Repository(BaseRepository): ...@@ -52,14 +52,13 @@ class Repository(BaseRepository):
constraint = parse_constraint(constraint) constraint = parse_constraint(constraint)
allow_prereleases = dependency.allows_prereleases() allow_prereleases = dependency.allows_prereleases()
if isinstance(constraint, VersionRange): if isinstance(constraint, VersionRange) and (
if ( constraint.max is not None
constraint.max is not None and constraint.max.is_unstable()
and constraint.max.is_unstable() or constraint.min is not None
or constraint.min is not None and constraint.min.is_unstable()
and constraint.min.is_unstable() ):
): allow_prereleases = True
allow_prereleases = True
for package in self.packages: for package in self.packages:
if dependency.name == package.name: if dependency.name == package.name:
...@@ -85,12 +84,9 @@ class Repository(BaseRepository): ...@@ -85,12 +84,9 @@ class Repository(BaseRepository):
def has_package(self, package: "Package") -> bool: def has_package(self, package: "Package") -> bool:
package_id = package.unique_name package_id = package.unique_name
return any(
for repo_package in self.packages: package_id == repo_package.unique_name for repo_package in self.packages
if package_id == repo_package.unique_name: )
return True
return False
def add_package(self, package: "Package") -> None: def add_package(self, package: "Package") -> None:
self._packages.append(package) self._packages.append(package)
......
import sys import sys
from contextlib import suppress
from typing import List from typing import List
from typing import Optional from typing import Optional
...@@ -20,10 +21,8 @@ def decode(string: str, encodings: Optional[List[str]] = None) -> str: ...@@ -20,10 +21,8 @@ def decode(string: str, encodings: Optional[List[str]] = None) -> str:
encodings = encodings or ["utf-8", "latin1", "ascii"] encodings = encodings or ["utf-8", "latin1", "ascii"]
for encoding in encodings: for encoding in encodings:
try: with suppress(UnicodeEncodeError, UnicodeDecodeError):
return string.decode(encoding) return string.decode(encoding)
except (UnicodeEncodeError, UnicodeDecodeError):
pass
return string.decode(encodings[0], errors="ignore") return string.decode(encodings[0], errors="ignore")
...@@ -35,10 +34,8 @@ def encode(string: str, encodings: Optional[List[str]] = None) -> bytes: ...@@ -35,10 +34,8 @@ def encode(string: str, encodings: Optional[List[str]] = None) -> bytes:
encodings = encodings or ["utf-8", "latin1", "ascii"] encodings = encodings or ["utf-8", "latin1", "ascii"]
for encoding in encodings: for encoding in encodings:
try: with suppress(UnicodeEncodeError, UnicodeDecodeError):
return string.encode(encoding) return string.encode(encoding)
except (UnicodeEncodeError, UnicodeDecodeError):
pass
return string.encode(encodings[0], errors="ignore") return string.encode(encodings[0], errors="ignore")
......
...@@ -615,11 +615,14 @@ class EnvManager: ...@@ -615,11 +615,14 @@ class EnvManager:
if not in_venv or env is not None: if not in_venv or env is not None:
# Checking if a local virtualenv exists # Checking if a local virtualenv exists
if self._poetry.config.get("virtualenvs.in-project") is not False: if (
if (cwd / ".venv").exists() and (cwd / ".venv").is_dir(): self._poetry.config.get("virtualenvs.in-project") is not False
venv = cwd / ".venv" and (cwd / ".venv").exists()
and (cwd / ".venv").is_dir()
):
venv = cwd / ".venv"
return VirtualEnv(venv) return VirtualEnv(venv)
create_venv = self._poetry.config.get("virtualenvs.create", True) create_venv = self._poetry.config.get("virtualenvs.create", True)
...@@ -1214,7 +1217,7 @@ class Env: ...@@ -1214,7 +1217,7 @@ class Env:
self.purelib, self.purelib,
self.platlib, self.platlib,
fallbacks, fallbacks,
skip_write_checks=False if fallbacks else True, skip_write_checks=not fallbacks,
) )
return self._site_packages return self._site_packages
......
...@@ -93,11 +93,10 @@ class Exporter: ...@@ -93,11 +93,10 @@ class Exporter:
else: else:
line = f"{package.name}=={package.version}" line = f"{package.name}=={package.version}"
if not is_direct_remote_reference: if not is_direct_remote_reference and ";" in requirement:
if ";" in requirement: markers = requirement.split(";", 1)[1].strip()
markers = requirement.split(";", 1)[1].strip() if markers:
if markers: line += f" ; {markers}"
line += f" ; {markers}"
if ( if (
not is_direct_remote_reference not is_direct_remote_reference
......
import logging import logging
from contextlib import suppress
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Dict from typing import Dict
from typing import Optional from typing import Optional
...@@ -185,9 +186,7 @@ class PasswordManager: ...@@ -185,9 +186,7 @@ class PasswordManager:
if not auth or "username" not in auth: if not auth or "username" not in auth:
return return
try: with suppress(KeyRingError):
self.keyring.delete_password(name, auth["username"]) self.keyring.delete_password(name, auth["username"])
except KeyRingError:
pass
self._config.auth_config_source.remove_property(f"http-basic.{name}") self._config.auth_config_source.remove_property(f"http-basic.{name}")
...@@ -99,11 +99,9 @@ class Shell: ...@@ -99,11 +99,9 @@ class Shell:
sys.exit(c.exitstatus) sys.exit(c.exitstatus)
def _get_activate_script(self) -> str: def _get_activate_script(self) -> str:
if "fish" == self._name: if self._name == "fish":
suffix = ".fish" suffix = ".fish"
elif "csh" == self._name: elif self._name in ("csh", "tcsh"):
suffix = ".csh"
elif "tcsh" == self._name:
suffix = ".csh" suffix = ".csh"
else: else:
suffix = "" suffix = ""
...@@ -111,13 +109,8 @@ class Shell: ...@@ -111,13 +109,8 @@ class Shell:
return "activate" + suffix return "activate" + suffix
def _get_source_command(self) -> str: def _get_source_command(self) -> str:
if "fish" == self._name: if self._name in ("fish", "csh", "tcsh"):
return "source"
elif "csh" == self._name:
return "source" return "source"
elif "tcsh" == self._name:
return "source"
return "." return "."
def __repr__(self) -> str: def __repr__(self) -> str:
......
...@@ -4,6 +4,7 @@ import shutil ...@@ -4,6 +4,7 @@ import shutil
import sys import sys
import tempfile import tempfile
from contextlib import suppress
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
...@@ -188,10 +189,8 @@ def download_mock(mocker): ...@@ -188,10 +189,8 @@ def download_mock(mocker):
def pep517_metadata_mock(mocker): def pep517_metadata_mock(mocker):
@classmethod @classmethod
def _pep517_metadata(cls, path): def _pep517_metadata(cls, path):
try: with suppress(PackageInfoError):
return PackageInfo.from_setup_files(path) return PackageInfo.from_setup_files(path)
except PackageInfoError:
pass
return PackageInfo(name="demo", version="0.1.2") return PackageInfo(name="demo", version="0.1.2")
mocker.patch( mocker.patch(
......
...@@ -60,5 +60,5 @@ Executable: {base_executable} ...@@ -60,5 +60,5 @@ Executable: {base_executable}
def test_env_info_displays_path_only(tester: "CommandTester"): def test_env_info_displays_path_only(tester: "CommandTester"):
tester.execute("--path") tester.execute("--path")
expected = str(Path("/prefix")) expected = str(Path("/prefix")) + "\n"
assert expected + "\n" == tester.io.fetch_output() assert tester.io.fetch_output() == expected
...@@ -58,7 +58,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -58,7 +58,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -80,9 +80,9 @@ Failed to add packages. Only vcs/path dependencies support editable installs. ca ...@@ -80,9 +80,9 @@ Failed to add packages. Only vcs/path dependencies support editable installs. ca
No changes were applied. No changes were applied.
""" """
assert 1 == tester.status_code assert tester.status_code == 1
assert expected == tester.io.fetch_error() assert expected == tester.io.fetch_error()
assert 0 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 0
assert content == app.poetry.file.read()["tool"]["poetry"] assert content == app.poetry.file.read()["tool"]["poetry"]
...@@ -107,7 +107,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -107,7 +107,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
def test_add_greater_constraint( def test_add_greater_constraint(
...@@ -131,7 +131,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -131,7 +131,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
def test_add_constraint_with_extras( def test_add_constraint_with_extras(
...@@ -162,7 +162,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -162,7 +162,7 @@ Package operations: 2 installs, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
def test_add_constraint_dependencies( def test_add_constraint_dependencies(
...@@ -192,7 +192,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -192,7 +192,7 @@ Package operations: 2 installs, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
def test_add_git_constraint( def test_add_git_constraint(
...@@ -222,7 +222,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -222,7 +222,7 @@ Package operations: 2 installs, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -258,7 +258,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -258,7 +258,7 @@ Package operations: 2 installs, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
def test_add_git_constraint_with_extras( def test_add_git_constraint_with_extras(
...@@ -291,7 +291,7 @@ Package operations: 4 installs, 0 updates, 0 removals ...@@ -291,7 +291,7 @@ Package operations: 4 installs, 0 updates, 0 removals
""" """
assert expected.strip() == tester.io.fetch_output().strip() assert expected.strip() == tester.io.fetch_output().strip()
assert 4 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 4
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -332,7 +332,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -332,7 +332,7 @@ Package operations: 2 installs, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -381,7 +381,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -381,7 +381,7 @@ Package operations: 2 installs, 0 updates, 0 removals
) )
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -424,7 +424,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -424,7 +424,7 @@ Package operations: 2 installs, 0 updates, 0 removals
) )
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
def test_add_file_constraint_wheel( def test_add_file_constraint_wheel(
...@@ -458,7 +458,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -458,7 +458,7 @@ Package operations: 2 installs, 0 updates, 0 removals
) )
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -498,7 +498,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -498,7 +498,7 @@ Package operations: 2 installs, 0 updates, 0 removals
) )
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -536,7 +536,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -536,7 +536,7 @@ Package operations: 2 installs, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -576,7 +576,7 @@ Package operations: 2 installs, 0 updates, 0 removals ...@@ -576,7 +576,7 @@ Package operations: 2 installs, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 2 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 2
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -618,7 +618,7 @@ Package operations: 4 installs, 0 updates, 0 removals ...@@ -618,7 +618,7 @@ Package operations: 4 installs, 0 updates, 0 removals
expected = set(expected.splitlines()) expected = set(expected.splitlines())
output = set(tester.io.fetch_output().splitlines()) output = set(tester.io.fetch_output().splitlines())
assert expected == output assert expected == output
assert 4 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 4
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -652,7 +652,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -652,7 +652,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -689,7 +689,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -689,7 +689,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -724,7 +724,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -724,7 +724,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -741,7 +741,7 @@ def test_add_constraint_with_source_that_does_not_exist( ...@@ -741,7 +741,7 @@ def test_add_constraint_with_source_that_does_not_exist(
with pytest.raises(ValueError) as e: with pytest.raises(ValueError) as e:
tester.execute("foo --source i-dont-exist") tester.execute("foo --source i-dont-exist")
assert 'Repository "i-dont-exist" does not exist.' == str(e.value) assert str(e.value) == 'Repository "i-dont-exist" does not exist.'
def test_add_constraint_not_found_with_source( def test_add_constraint_not_found_with_source(
...@@ -761,7 +761,7 @@ def test_add_constraint_not_found_with_source( ...@@ -761,7 +761,7 @@ def test_add_constraint_not_found_with_source(
with pytest.raises(ValueError) as e: with pytest.raises(ValueError) as e:
tester.execute("cachy --source my-index") tester.execute("cachy --source my-index")
assert "Could not find a matching version of package cachy" == str(e.value) assert str(e.value) == "Could not find a matching version of package cachy"
def test_add_to_section_that_does_not_exist_yet( def test_add_to_section_that_does_not_exist_yet(
...@@ -786,7 +786,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -786,7 +786,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -827,7 +827,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -827,7 +827,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -857,7 +857,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -857,7 +857,7 @@ Package operations: 1 install, 0 updates, 0 removals
""" """
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
assert 1 == tester.command.installer.executor.installations_count assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"] content = app.poetry.file.read()["tool"]["poetry"]
...@@ -1696,7 +1696,7 @@ def test_add_constraint_with_source_that_does_not_exist_old_installer( ...@@ -1696,7 +1696,7 @@ def test_add_constraint_with_source_that_does_not_exist_old_installer(
with pytest.raises(ValueError) as e: with pytest.raises(ValueError) as e:
old_tester.execute("foo --source i-dont-exist") old_tester.execute("foo --source i-dont-exist")
assert 'Repository "i-dont-exist" does not exist.' == str(e.value) assert str(e.value) == 'Repository "i-dont-exist" does not exist.'
def test_add_constraint_not_found_with_source_old_installer( def test_add_constraint_not_found_with_source_old_installer(
...@@ -1716,7 +1716,7 @@ def test_add_constraint_not_found_with_source_old_installer( ...@@ -1716,7 +1716,7 @@ def test_add_constraint_not_found_with_source_old_installer(
with pytest.raises(ValueError) as e: with pytest.raises(ValueError) as e:
old_tester.execute("cachy --source my-index") old_tester.execute("cachy --source my-index")
assert "Could not find a matching version of package cachy" == str(e.value) assert str(e.value) == "Could not find a matching version of package cachy"
def test_add_to_section_that_does_no_exist_yet_old_installer( def test_add_to_section_that_does_no_exist_yet_old_installer(
......
...@@ -36,7 +36,7 @@ def test_show_config_with_local_config_file_empty( ...@@ -36,7 +36,7 @@ def test_show_config_with_local_config_file_empty(
) )
tester.execute() tester.execute()
assert "" == tester.io.fetch_output() assert tester.io.fetch_output() == ""
def test_list_displays_default_value_if_not_set( def test_list_displays_default_value_if_not_set(
...@@ -82,7 +82,7 @@ virtualenvs.path = {path} # {virtualenvs} ...@@ -82,7 +82,7 @@ virtualenvs.path = {path} # {virtualenvs}
virtualenvs=str(config_cache_dir / "virtualenvs"), virtualenvs=str(config_cache_dir / "virtualenvs"),
) )
assert 0 == config.set_config_source.call_count assert config.set_config_source.call_count == 0
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
...@@ -130,7 +130,7 @@ virtualenvs.path = {path} # {virtualenvs} ...@@ -130,7 +130,7 @@ virtualenvs.path = {path} # {virtualenvs}
virtualenvs=str(config_cache_dir / "virtualenvs"), virtualenvs=str(config_cache_dir / "virtualenvs"),
) )
assert 1 == config.set_config_source.call_count assert config.set_config_source.call_count == 1
assert expected == tester.io.fetch_output() assert expected == tester.io.fetch_output()
...@@ -140,7 +140,7 @@ def test_set_pypi_token( ...@@ -140,7 +140,7 @@ def test_set_pypi_token(
tester.execute("pypi-token.pypi mytoken") tester.execute("pypi-token.pypi mytoken")
tester.execute("--list") tester.execute("--list")
assert "mytoken" == auth_config_source.config["pypi-token"]["pypi"] assert auth_config_source.config["pypi-token"]["pypi"] == "mytoken"
def test_set_client_cert( def test_set_client_cert(
...@@ -153,8 +153,8 @@ def test_set_client_cert( ...@@ -153,8 +153,8 @@ def test_set_client_cert(
tester.execute("certificates.foo.client-cert path/to/cert.pem") tester.execute("certificates.foo.client-cert path/to/cert.pem")
assert ( assert (
"path/to/cert.pem" auth_config_source.config["certificates"]["foo"]["client-cert"]
== auth_config_source.config["certificates"]["foo"]["client-cert"] == "path/to/cert.pem"
) )
...@@ -167,7 +167,7 @@ def test_set_cert( ...@@ -167,7 +167,7 @@ def test_set_cert(
tester.execute("certificates.foo.cert path/to/ca.pem") tester.execute("certificates.foo.cert path/to/ca.pem")
assert "path/to/ca.pem" == auth_config_source.config["certificates"]["foo"]["cert"] assert auth_config_source.config["certificates"]["foo"]["cert"] == "path/to/ca.pem"
def test_config_installer_parallel( def test_config_installer_parallel(
......
...@@ -112,7 +112,7 @@ def test_noninteractive( ...@@ -112,7 +112,7 @@ def test_noninteractive(
expected = "Using version ^3.6.0 for pytest\n" expected = "Using version ^3.6.0 for pytest\n"
assert tester.io.fetch_output() == expected assert tester.io.fetch_output() == expected
assert "" == tester.io.fetch_error() assert tester.io.fetch_error() == ""
toml_content = (tmp_path / "pyproject.toml").read_text() toml_content = (tmp_path / "pyproject.toml").read_text()
assert 'name = "my-package"' in toml_content assert 'name = "my-package"' in toml_content
......
...@@ -29,7 +29,7 @@ def test_publish_returns_non_zero_code_for_upload_errors( ...@@ -29,7 +29,7 @@ def test_publish_returns_non_zero_code_for_upload_errors(
exit_code = app_tester.execute("publish --username foo --password bar") exit_code = app_tester.execute("publish --username foo --password bar")
assert 1 == exit_code assert exit_code == 1
expected_output = """ expected_output = """
Publishing simple-project (1.2.3) to PyPI Publishing simple-project (1.2.3) to PyPI
...@@ -59,7 +59,7 @@ def test_publish_returns_non_zero_code_for_connection_errors( ...@@ -59,7 +59,7 @@ def test_publish_returns_non_zero_code_for_connection_errors(
exit_code = app_tester.execute("publish --username foo --password bar") exit_code = app_tester.execute("publish --username foo --password bar")
assert 1 == exit_code assert exit_code == 1
expected = str(UploadError(error=requests.ConnectionError())) expected = str(UploadError(error=requests.ConnectionError()))
...@@ -96,7 +96,7 @@ def test_publish_dry_run( ...@@ -96,7 +96,7 @@ def test_publish_dry_run(
exit_code = app_tester.execute("publish --dry-run --username foo --password bar") exit_code = app_tester.execute("publish --dry-run --username foo --password bar")
assert 0 == exit_code assert exit_code == 0
output = app_tester.io.fetch_output() output = app_tester.io.fetch_output()
error = app_tester.io.fetch_error() error = app_tester.io.fetch_error()
......
...@@ -55,19 +55,19 @@ def test_increment_version( ...@@ -55,19 +55,19 @@ def test_increment_version(
def test_version_show(tester: "CommandTester"): def test_version_show(tester: "CommandTester"):
tester.execute() tester.execute()
assert "simple-project 1.2.3\n" == tester.io.fetch_output() 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"):
tester.execute("--short") tester.execute("--short")
assert "1.2.3\n" == tester.io.fetch_output() assert tester.io.fetch_output() == "1.2.3\n"
def test_version_update(tester: "CommandTester"): def test_version_update(tester: "CommandTester"):
tester.execute("2.0.0") tester.execute("2.0.0")
assert "Bumping version from 1.2.3 to 2.0.0\n" == tester.io.fetch_output() 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"):
tester.execute("--short 2.0.0") tester.execute("--short 2.0.0")
assert "2.0.0\n" == tester.io.fetch_output() assert tester.io.fetch_output() == "2.0.0\n"
...@@ -46,7 +46,7 @@ def test_application_with_plugins(mocker: "MockerFixture"): ...@@ -46,7 +46,7 @@ def test_application_with_plugins(mocker: "MockerFixture"):
tester.execute("") tester.execute("")
assert re.search(r"\s+foo\s+Foo Command", tester.io.fetch_output()) is not None assert re.search(r"\s+foo\s+Foo Command", tester.io.fetch_output()) is not None
assert 0 == tester.status_code assert tester.status_code == 0
def test_application_with_plugins_disabled(mocker: "MockerFixture"): def test_application_with_plugins_disabled(mocker: "MockerFixture"):
...@@ -65,7 +65,7 @@ def test_application_with_plugins_disabled(mocker: "MockerFixture"): ...@@ -65,7 +65,7 @@ def test_application_with_plugins_disabled(mocker: "MockerFixture"):
tester.execute("--no-plugins") tester.execute("--no-plugins")
assert re.search(r"\s+foo\s+Foo Command", tester.io.fetch_output()) is None assert re.search(r"\s+foo\s+Foo Command", tester.io.fetch_output()) is None
assert 0 == tester.status_code assert tester.status_code == 0
def test_application_execute_plugin_command(mocker: "MockerFixture"): def test_application_execute_plugin_command(mocker: "MockerFixture"):
...@@ -83,8 +83,8 @@ def test_application_execute_plugin_command(mocker: "MockerFixture"): ...@@ -83,8 +83,8 @@ def test_application_execute_plugin_command(mocker: "MockerFixture"):
tester = ApplicationTester(app) tester = ApplicationTester(app)
tester.execute("foo") tester.execute("foo")
assert "foo called\n" == tester.io.fetch_output() assert tester.io.fetch_output() == "foo called\n"
assert 0 == tester.status_code assert tester.status_code == 0
def test_application_execute_plugin_command_with_plugins_disabled( def test_application_execute_plugin_command_with_plugins_disabled(
...@@ -104,6 +104,6 @@ def test_application_execute_plugin_command_with_plugins_disabled( ...@@ -104,6 +104,6 @@ def test_application_execute_plugin_command_with_plugins_disabled(
tester = ApplicationTester(app) tester = ApplicationTester(app)
tester.execute("foo --no-plugins") tester.execute("foo --no-plugins")
assert "" == tester.io.fetch_output() assert tester.io.fetch_output() == ""
assert '\nThe command "foo" does not exist.\n' == tester.io.fetch_error() assert tester.io.fetch_error() == '\nThe command "foo" does not exist.\n'
assert 1 == tester.status_code assert tester.status_code == 1
...@@ -121,7 +121,7 @@ def test_chooser_chooses_universal_wheel_link_if_available( ...@@ -121,7 +121,7 @@ def test_chooser_chooses_universal_wheel_link_if_available(
link = chooser.choose_for(package) link = chooser.choose_for(package)
assert "pytest-3.5.0-py2.py3-none-any.whl" == link.filename assert link.filename == "pytest-3.5.0-py2.py3-none-any.whl"
@pytest.mark.parametrize("source_type", ["", "legacy"]) @pytest.mark.parametrize("source_type", ["", "legacy"])
...@@ -142,7 +142,7 @@ def test_chooser_chooses_specific_python_universal_wheel_link_if_available( ...@@ -142,7 +142,7 @@ def test_chooser_chooses_specific_python_universal_wheel_link_if_available(
link = chooser.choose_for(package) link = chooser.choose_for(package)
assert "isort-4.3.4-py3-none-any.whl" == link.filename assert link.filename == "isort-4.3.4-py3-none-any.whl"
@pytest.mark.parametrize("source_type", ["", "legacy"]) @pytest.mark.parametrize("source_type", ["", "legacy"])
...@@ -166,7 +166,7 @@ def test_chooser_chooses_system_specific_wheel_link_if_available( ...@@ -166,7 +166,7 @@ def test_chooser_chooses_system_specific_wheel_link_if_available(
link = chooser.choose_for(package) link = chooser.choose_for(package)
assert "PyYAML-3.13-cp37-cp37m-win32.whl" == link.filename assert link.filename == "PyYAML-3.13-cp37-cp37m-win32.whl"
@pytest.mark.parametrize("source_type", ["", "legacy"]) @pytest.mark.parametrize("source_type", ["", "legacy"])
...@@ -191,7 +191,7 @@ def test_chooser_chooses_sdist_if_no_compatible_wheel_link_is_available( ...@@ -191,7 +191,7 @@ def test_chooser_chooses_sdist_if_no_compatible_wheel_link_is_available(
link = chooser.choose_for(package) link = chooser.choose_for(package)
assert "PyYAML-3.13.tar.gz" == link.filename assert link.filename == "PyYAML-3.13.tar.gz"
@pytest.mark.parametrize("source_type", ["", "legacy"]) @pytest.mark.parametrize("source_type", ["", "legacy"])
...@@ -224,7 +224,7 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes( ...@@ -224,7 +224,7 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes(
link = chooser.choose_for(package) link = chooser.choose_for(package)
assert "isort-4.3.4.tar.gz" == link.filename assert link.filename == "isort-4.3.4.tar.gz"
@pytest.mark.parametrize("source_type", ["", "legacy"]) @pytest.mark.parametrize("source_type", ["", "legacy"])
......
...@@ -178,8 +178,8 @@ Package operations: 4 installs, 1 update, 1 removal ...@@ -178,8 +178,8 @@ Package operations: 4 installs, 1 update, 1 removal
expected = set(expected.splitlines()) expected = set(expected.splitlines())
output = set(io.fetch_output().splitlines()) output = set(io.fetch_output().splitlines())
assert expected == output assert expected == output
assert 5 == len(env.executed) assert len(env.executed) == 5
assert 0 == return_code assert return_code == 0
pip_editable_install.assert_called_once() pip_editable_install.assert_called_once()
...@@ -192,8 +192,11 @@ def test_execute_shows_skipped_operations_if_verbose( ...@@ -192,8 +192,11 @@ def test_execute_shows_skipped_operations_if_verbose(
executor = Executor(env, pool, config, io) executor = Executor(env, pool, config, io)
executor.verbose() executor.verbose()
assert 0 == executor.execute( assert (
[Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed")] executor.execute(
[Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed")]
)
== 0
) )
expected = """ expected = """
...@@ -202,7 +205,7 @@ Package operations: 0 installs, 0 updates, 0 removals, 1 skipped ...@@ -202,7 +205,7 @@ Package operations: 0 installs, 0 updates, 0 removals, 1 skipped
• Removing clikit (0.2.3): Skipped for the following reason: Not currently installed • Removing clikit (0.2.3): Skipped for the following reason: Not currently installed
""" """
assert expected == io.fetch_output() assert expected == io.fetch_output()
assert 0 == len(env.executed) assert len(env.executed) == 0
def test_execute_should_show_errors( def test_execute_should_show_errors(
...@@ -213,7 +216,7 @@ def test_execute_should_show_errors( ...@@ -213,7 +216,7 @@ def test_execute_should_show_errors(
mocker.patch.object(executor, "_install", side_effect=Exception("It failed!")) mocker.patch.object(executor, "_install", side_effect=Exception("It failed!"))
assert 1 == executor.execute([Install(Package("clikit", "0.2.3"))]) assert executor.execute([Install(Package("clikit", "0.2.3"))]) == 1
expected = """ expected = """
Package operations: 1 install, 0 updates, 0 removals Package operations: 1 install, 0 updates, 0 removals
...@@ -265,7 +268,7 @@ def test_execute_works_with_ansi_output( ...@@ -265,7 +268,7 @@ def test_execute_works_with_ansi_output(
for line in expected: for line in expected:
assert line in output assert line in output
assert 0 == return_code assert return_code == 0
def test_execute_works_with_no_ansi_output( def test_execute_works_with_no_ansi_output(
...@@ -301,7 +304,7 @@ Package operations: 1 install, 0 updates, 0 removals ...@@ -301,7 +304,7 @@ Package operations: 1 install, 0 updates, 0 removals
expected = set(expected.splitlines()) expected = set(expected.splitlines())
output = set(io_not_decorated.fetch_output().splitlines()) output = set(io_not_decorated.fetch_output().splitlines())
assert expected == output assert expected == output
assert 0 == return_code assert return_code == 0
def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_interrupt( def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_interrupt(
...@@ -313,7 +316,7 @@ def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_inter ...@@ -313,7 +316,7 @@ def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_inter
# A return code of -2 means KeyboardInterrupt in the pip subprocess # A return code of -2 means KeyboardInterrupt in the pip subprocess
mocker.patch.object(executor, "_install", return_value=-2) mocker.patch.object(executor, "_install", return_value=-2)
assert 1 == executor.execute([Install(Package("clikit", "0.2.3"))]) assert executor.execute([Install(Package("clikit", "0.2.3"))]) == 1
expected = """ expected = """
Package operations: 1 install, 0 updates, 0 removals Package operations: 1 install, 0 updates, 0 removals
...@@ -340,7 +343,7 @@ def test_execute_should_gracefully_handle_io_error( ...@@ -340,7 +343,7 @@ def test_execute_should_gracefully_handle_io_error(
mocker.patch.object(io, "write_line", side_effect=write_line) mocker.patch.object(io, "write_line", side_effect=write_line)
assert 1 == executor.execute([Install(Package("clikit", "0.2.3"))]) assert executor.execute([Install(Package("clikit", "0.2.3"))]) == 1
expected = r""" expected = r"""
Package operations: 1 install, 0 updates, 0 removals Package operations: 1 install, 0 updates, 0 removals
......
...@@ -301,9 +301,9 @@ def test_run_update_after_removing_dependencies( ...@@ -301,9 +301,9 @@ def test_run_update_after_removing_dependencies(
assert locker.written_data == expected assert locker.written_data == expected
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 1 == installer.executor.removals_count assert installer.executor.removals_count == 1
def _configure_run_install_dev( def _configure_run_install_dev(
...@@ -387,9 +387,9 @@ def test_run_install_no_group( ...@@ -387,9 +387,9 @@ def test_run_install_no_group(
installer.without_groups(["dev"]) installer.without_groups(["dev"])
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_run_install_group_only( def test_run_install_group_only(
...@@ -404,9 +404,9 @@ def test_run_install_group_only( ...@@ -404,9 +404,9 @@ def test_run_install_group_only(
installer.only_groups(["dev"]) installer.only_groups(["dev"])
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_run_install_with_optional_group_not_selected( def test_run_install_with_optional_group_not_selected(
...@@ -422,9 +422,9 @@ def test_run_install_with_optional_group_not_selected( ...@@ -422,9 +422,9 @@ def test_run_install_with_optional_group_not_selected(
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_run_install_does_not_remove_locked_packages_if_installed_but_not_required( def test_run_install_does_not_remove_locked_packages_if_installed_but_not_required(
...@@ -492,9 +492,9 @@ def test_run_install_does_not_remove_locked_packages_if_installed_but_not_requir ...@@ -492,9 +492,9 @@ def test_run_install_does_not_remove_locked_packages_if_installed_but_not_requir
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_run_install_removes_locked_packages_if_installed_and_synchronization_is_required( def test_run_install_removes_locked_packages_if_installed_and_synchronization_is_required(
...@@ -563,9 +563,9 @@ def test_run_install_removes_locked_packages_if_installed_and_synchronization_is ...@@ -563,9 +563,9 @@ def test_run_install_removes_locked_packages_if_installed_and_synchronization_is
installer.requires_synchronization(True) installer.requires_synchronization(True)
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 2 == installer.executor.removals_count assert installer.executor.removals_count == 2
def test_run_install_removes_no_longer_locked_packages_if_installed( def test_run_install_removes_no_longer_locked_packages_if_installed(
...@@ -634,9 +634,9 @@ def test_run_install_removes_no_longer_locked_packages_if_installed( ...@@ -634,9 +634,9 @@ def test_run_install_removes_no_longer_locked_packages_if_installed(
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 2 == installer.executor.removals_count assert installer.executor.removals_count == 2
def test_run_install_with_optional_group_selected( def test_run_install_with_optional_group_selected(
...@@ -653,9 +653,9 @@ def test_run_install_with_optional_group_selected( ...@@ -653,9 +653,9 @@ def test_run_install_with_optional_group_selected(
installer.with_groups(["dev"]) installer.with_groups(["dev"])
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
@pytest.mark.parametrize( @pytest.mark.parametrize(
...@@ -731,8 +731,8 @@ def test_run_install_with_synchronization( ...@@ -731,8 +731,8 @@ def test_run_install_with_synchronization(
installer.requires_synchronization(True) installer.requires_synchronization(True)
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 2 + len(managed_reserved_packages) == installer.executor.removals_count assert 2 + len(managed_reserved_packages) == installer.executor.removals_count
expected_removals = { expected_removals = {
...@@ -841,9 +841,9 @@ def test_run_whitelist_remove( ...@@ -841,9 +841,9 @@ def test_run_whitelist_remove(
expected = fixture("remove") expected = fixture("remove")
assert locker.written_data == expected assert locker.written_data == expected
assert 1 == installer.executor.installations_count assert installer.executor.installations_count == 1
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 1 == installer.executor.removals_count assert installer.executor.removals_count == 1
def test_add_with_sub_dependencies( def test_add_with_sub_dependencies(
...@@ -934,9 +934,9 @@ def test_run_with_optional_and_python_restricted_dependencies( ...@@ -934,9 +934,9 @@ def test_run_with_optional_and_python_restricted_dependencies(
# We should only have 2 installs: # We should only have 2 installs:
# C,D since python version is not compatible # C,D since python version is not compatible
# with B's python constraint and A is optional # with B's python constraint and A is optional
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
assert "d" == installer.executor.installations[0].name assert installer.executor.installations[0].name == "d"
assert "c" == installer.executor.installations[1].name assert installer.executor.installations[1].name == "c"
def test_run_with_optional_and_platform_restricted_dependencies( def test_run_with_optional_and_platform_restricted_dependencies(
...@@ -980,9 +980,9 @@ def test_run_with_optional_and_platform_restricted_dependencies( ...@@ -980,9 +980,9 @@ def test_run_with_optional_and_platform_restricted_dependencies(
# We should only have 2 installs: # We should only have 2 installs:
# C,D since the mocked python version is not compatible # C,D since the mocked python version is not compatible
# with B's python constraint and A is optional # with B's python constraint and A is optional
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
assert "d" == installer.executor.installations[0].name assert installer.executor.installations[0].name == "d"
assert "c" == installer.executor.installations[1].name assert installer.executor.installations[1].name == "c"
def test_run_with_dependencies_extras( def test_run_with_dependencies_extras(
...@@ -1071,7 +1071,7 @@ def test_run_does_not_install_extras_if_not_requested( ...@@ -1071,7 +1071,7 @@ def test_run_does_not_install_extras_if_not_requested(
assert locker.written_data == expected assert locker.written_data == expected
# But should not be installed # But should not be installed
assert 3 == installer.executor.installations_count # A, B, C assert installer.executor.installations_count == 3 # A, B, C
def test_run_installs_extras_if_requested( def test_run_installs_extras_if_requested(
...@@ -1103,7 +1103,7 @@ def test_run_installs_extras_if_requested( ...@@ -1103,7 +1103,7 @@ def test_run_installs_extras_if_requested(
assert locker.written_data == expected assert locker.written_data == expected
# But should not be installed # But should not be installed
assert 4 == installer.executor.installations_count # A, B, C, D assert installer.executor.installations_count == 4 # A, B, C, D
def test_run_installs_extras_with_deps_if_requested( def test_run_installs_extras_with_deps_if_requested(
...@@ -1136,7 +1136,7 @@ def test_run_installs_extras_with_deps_if_requested( ...@@ -1136,7 +1136,7 @@ def test_run_installs_extras_with_deps_if_requested(
assert locker.written_data == expected assert locker.written_data == expected
# But should not be installed # But should not be installed
assert 4 == installer.executor.installations_count # A, B, C, D assert installer.executor.installations_count == 4 # A, B, C, D
def test_run_installs_extras_with_deps_if_requested_locked( def test_run_installs_extras_with_deps_if_requested_locked(
...@@ -1167,7 +1167,7 @@ def test_run_installs_extras_with_deps_if_requested_locked( ...@@ -1167,7 +1167,7 @@ def test_run_installs_extras_with_deps_if_requested_locked(
installer.run() installer.run()
# But should not be installed # But should not be installed
assert 4 == installer.executor.installations_count # A, B, C, D assert installer.executor.installations_count == 4 # A, B, C, D
def test_installer_with_pypi_repository( def test_installer_with_pypi_repository(
...@@ -1207,7 +1207,7 @@ def test_run_installs_with_local_file( ...@@ -1207,7 +1207,7 @@ def test_run_installs_with_local_file(
expected = fixture("with-file-dependency") expected = fixture("with-file-dependency")
assert locker.written_data == expected assert locker.written_data == expected
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
def test_run_installs_wheel_with_no_requires_dist( def test_run_installs_wheel_with_no_requires_dist(
...@@ -1228,7 +1228,7 @@ def test_run_installs_wheel_with_no_requires_dist( ...@@ -1228,7 +1228,7 @@ def test_run_installs_wheel_with_no_requires_dist(
assert locker.written_data == expected assert locker.written_data == expected
assert 1 == installer.executor.installations_count assert installer.executor.installations_count == 1
def test_run_installs_with_local_poetry_directory_and_extras( def test_run_installs_with_local_poetry_directory_and_extras(
...@@ -1253,7 +1253,7 @@ def test_run_installs_with_local_poetry_directory_and_extras( ...@@ -1253,7 +1253,7 @@ def test_run_installs_with_local_poetry_directory_and_extras(
expected = fixture("with-directory-dependency-poetry") expected = fixture("with-directory-dependency-poetry")
assert locker.written_data == expected assert locker.written_data == expected
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
def test_run_installs_with_local_poetry_directory_transitive( def test_run_installs_with_local_poetry_directory_transitive(
...@@ -1285,7 +1285,7 @@ def test_run_installs_with_local_poetry_directory_transitive( ...@@ -1285,7 +1285,7 @@ def test_run_installs_with_local_poetry_directory_transitive(
assert locker.written_data == expected assert locker.written_data == expected
assert 6 == installer.executor.installations_count assert installer.executor.installations_count == 6
def test_run_installs_with_local_poetry_file_transitive( def test_run_installs_with_local_poetry_file_transitive(
...@@ -1319,7 +1319,7 @@ def test_run_installs_with_local_poetry_file_transitive( ...@@ -1319,7 +1319,7 @@ def test_run_installs_with_local_poetry_file_transitive(
assert locker.written_data == expected assert locker.written_data == expected
assert 4 == installer.executor.installations_count assert installer.executor.installations_count == 4
def test_run_installs_with_local_setuptools_directory( def test_run_installs_with_local_setuptools_directory(
...@@ -1343,7 +1343,7 @@ def test_run_installs_with_local_setuptools_directory( ...@@ -1343,7 +1343,7 @@ def test_run_installs_with_local_setuptools_directory(
expected = fixture("with-directory-dependency-setuptools") expected = fixture("with-directory-dependency-setuptools")
assert locker.written_data == expected assert locker.written_data == expected
assert 3 == installer.executor.installations_count assert installer.executor.installations_count == 3
def test_run_with_prereleases( def test_run_with_prereleases(
...@@ -1583,13 +1583,13 @@ def test_run_install_duplicate_dependencies_different_constraints( ...@@ -1583,13 +1583,13 @@ def test_run_install_duplicate_dependencies_different_constraints(
assert locker.written_data == expected assert locker.written_data == expected
installs = installer.executor.installations installs = installer.executor.installations
assert 3 == installer.executor.installations_count assert installer.executor.installations_count == 3
assert installs[0] == package_c12 assert installs[0] == package_c12
assert installs[1] == package_b10 assert installs[1] == package_b10
assert installs[2] == package_a assert installs[2] == package_a
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_run_install_duplicate_dependencies_different_constraints_with_lock( def test_run_install_duplicate_dependencies_different_constraints_with_lock(
...@@ -1694,9 +1694,9 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock( ...@@ -1694,9 +1694,9 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock(
assert locker.written_data == expected assert locker.written_data == expected
assert 3 == installer.executor.installations_count assert installer.executor.installations_count == 3
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_run_update_uninstalls_after_removal_transient_dependency( def test_run_update_uninstalls_after_removal_transient_dependency(
...@@ -1756,9 +1756,9 @@ def test_run_update_uninstalls_after_removal_transient_dependency( ...@@ -1756,9 +1756,9 @@ def test_run_update_uninstalls_after_removal_transient_dependency(
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 0 == installer.executor.installations_count assert installer.executor.installations_count == 0
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 1 == installer.executor.removals_count assert installer.executor.removals_count == 1
def test_run_install_duplicate_dependencies_different_constraints_with_lock_update( def test_run_install_duplicate_dependencies_different_constraints_with_lock_update(
...@@ -1865,9 +1865,9 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock_upda ...@@ -1865,9 +1865,9 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock_upda
assert locker.written_data == expected assert locker.written_data == expected
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
assert 1 == installer.executor.updates_count assert installer.executor.updates_count == 1
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
@pytest.mark.skip( @pytest.mark.skip(
...@@ -1898,7 +1898,7 @@ def test_installer_test_solver_finds_compatible_package_for_dependency_python_no ...@@ -1898,7 +1898,7 @@ def test_installer_test_solver_finds_compatible_package_for_dependency_python_no
expected = fixture("with-conditional-dependency") expected = fixture("with-conditional-dependency")
assert locker.written_data == expected assert locker.written_data == expected
assert 1 == installer.executor.installations_count assert installer.executor.installations_count == 1
def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency( def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency(
...@@ -1935,9 +1935,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de ...@@ -1935,9 +1935,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 3 == installer.executor.installations_count assert installer.executor.installations_count == 3
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
package.add_dependency(Factory.create_dependency("D", "^1.0")) package.add_dependency(Factory.create_dependency("D", "^1.0"))
locker.locked(True) locker.locked(True)
...@@ -1963,9 +1963,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de ...@@ -1963,9 +1963,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
installer.whitelist(["D"]) installer.whitelist(["D"])
installer.run() installer.run()
assert 1 == installer.executor.installations_count assert installer.executor.installations_count == 1
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency_pypi_repository( def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency_pypi_repository(
...@@ -1999,9 +1999,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de ...@@ -1999,9 +1999,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 3 == installer.executor.installations_count assert installer.executor.installations_count == 3
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
package.add_dependency(Factory.create_dependency("pytest", "^3.5")) package.add_dependency(Factory.create_dependency("pytest", "^3.5"))
...@@ -2027,9 +2027,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de ...@@ -2027,9 +2027,9 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
installer.whitelist(["pytest"]) installer.whitelist(["pytest"])
installer.run() installer.run()
assert 7 == installer.executor.installations_count assert installer.executor.installations_count == 7
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_installer_required_extras_should_be_installed( def test_installer_required_extras_should_be_installed(
...@@ -2064,9 +2064,9 @@ def test_installer_required_extras_should_be_installed( ...@@ -2064,9 +2064,9 @@ def test_installer_required_extras_should_be_installed(
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
locker.locked(True) locker.locked(True)
locker.mock_lock_data(locker.written_data) locker.mock_lock_data(locker.written_data)
...@@ -2086,9 +2086,9 @@ def test_installer_required_extras_should_be_installed( ...@@ -2086,9 +2086,9 @@ def test_installer_required_extras_should_be_installed(
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_update_multiple_times_with_split_dependencies_is_idempotent( def test_update_multiple_times_with_split_dependencies_is_idempotent(
...@@ -2201,9 +2201,9 @@ def test_installer_can_install_dependencies_from_forced_source( ...@@ -2201,9 +2201,9 @@ def test_installer_can_install_dependencies_from_forced_source(
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 1 == installer.executor.installations_count assert installer.executor.installations_count == 1
assert 0 == installer.executor.updates_count assert installer.executor.updates_count == 0
assert 0 == installer.executor.removals_count assert installer.executor.removals_count == 0
def test_run_installs_with_url_file( def test_run_installs_with_url_file(
...@@ -2220,7 +2220,7 @@ def test_run_installs_with_url_file( ...@@ -2220,7 +2220,7 @@ def test_run_installs_with_url_file(
assert locker.written_data == expected assert locker.written_data == expected
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
def test_installer_uses_prereleases_if_they_are_compatible( def test_installer_uses_prereleases_if_they_are_compatible(
...@@ -2250,7 +2250,7 @@ def test_installer_uses_prereleases_if_they_are_compatible( ...@@ -2250,7 +2250,7 @@ def test_installer_uses_prereleases_if_they_are_compatible(
installer.update(True) installer.update(True)
installer.run() installer.run()
assert 2 == installer.executor.installations_count assert installer.executor.installations_count == 2
def test_installer_can_handle_old_lock_files( def test_installer_can_handle_old_lock_files(
...@@ -2283,7 +2283,7 @@ def test_installer_can_handle_old_lock_files( ...@@ -2283,7 +2283,7 @@ def test_installer_can_handle_old_lock_files(
installer.run() installer.run()
assert 6 == installer.executor.installations_count assert installer.executor.installations_count == 6
installer = Installer( installer = Installer(
NullIO(), NullIO(),
...@@ -2305,7 +2305,7 @@ def test_installer_can_handle_old_lock_files( ...@@ -2305,7 +2305,7 @@ def test_installer_can_handle_old_lock_files(
installer.run() installer.run()
# funcsigs will be added # funcsigs will be added
assert 7 == installer.executor.installations_count assert installer.executor.installations_count == 7
installer = Installer( installer = Installer(
NullIO(), NullIO(),
...@@ -2327,7 +2327,7 @@ def test_installer_can_handle_old_lock_files( ...@@ -2327,7 +2327,7 @@ def test_installer_can_handle_old_lock_files(
installer.run() installer.run()
# colorama will be added # colorama will be added
assert 8 == installer.executor.installations_count assert installer.executor.installations_count == 8
@pytest.mark.parametrize("quiet", [True, False]) @pytest.mark.parametrize("quiet", [True, False])
......
...@@ -1888,7 +1888,7 @@ def test_installer_can_handle_old_lock_files( ...@@ -1888,7 +1888,7 @@ def test_installer_can_handle_old_lock_files(
installer.run() installer.run()
assert 6 == len(installer.installer.installs) assert len(installer.installer.installs) == 6
installer = Installer( installer = Installer(
NullIO(), NullIO(),
...@@ -1903,7 +1903,7 @@ def test_installer_can_handle_old_lock_files( ...@@ -1903,7 +1903,7 @@ def test_installer_can_handle_old_lock_files(
installer.run() installer.run()
# funcsigs will be added # funcsigs will be added
assert 7 == len(installer.installer.installs) assert len(installer.installer.installs) == 7
installer = Installer( installer = Installer(
NullIO(), NullIO(),
...@@ -1918,4 +1918,4 @@ def test_installer_can_handle_old_lock_files( ...@@ -1918,4 +1918,4 @@ def test_installer_can_handle_old_lock_files(
installer.run() installer.run()
# colorama will be added # colorama will be added
assert 8 == len(installer.installer.installs) assert len(installer.installer.installs) == 8
...@@ -101,10 +101,10 @@ def test_builder_installs_proper_files_for_standard_packages( ...@@ -101,10 +101,10 @@ def test_builder_installs_proper_files_for_standard_packages(
assert dist_info.joinpath("RECORD").exists() assert dist_info.joinpath("RECORD").exists()
assert dist_info.joinpath("entry_points.txt").exists() assert dist_info.joinpath("entry_points.txt").exists()
assert "poetry" == dist_info.joinpath("INSTALLER").read_text() assert dist_info.joinpath("INSTALLER").read_text() == "poetry"
assert ( assert (
"[console_scripts]\nbaz=bar:baz.boom.bim\nfoo=foo:bar\nfox=fuz.foo:bar.baz\n\n" dist_info.joinpath("entry_points.txt").read_text()
== dist_info.joinpath("entry_points.txt").read_text() == "[console_scripts]\nbaz=bar:baz.boom.bim\nfoo=foo:bar\nfox=fuz.foo:bar.baz\n\n"
) )
metadata = """\ metadata = """\
......
...@@ -140,11 +140,11 @@ cachecontrol = [] ...@@ -140,11 +140,11 @@ cachecontrol = []
packages = locker.locked_repository().packages packages = locker.locked_repository().packages
assert 1 == len(packages) assert len(packages) == 1
package = packages[0] package = packages[0]
assert 3 == len(package.requires) assert len(package.requires) == 3
assert 2 == len(package.extras) assert len(package.extras) == 2
lockfile_dep = package.extras["filecache"][0] lockfile_dep = package.extras["filecache"][0]
assert lockfile_dep.name == "lockfile" assert lockfile_dep.name == "lockfile"
...@@ -202,7 +202,7 @@ content-hash = "123456789" ...@@ -202,7 +202,7 @@ content-hash = "123456789"
locker.lock.write(tomlkit.parse(content)) locker.lock.write(tomlkit.parse(content))
repository = locker.locked_repository() repository = locker.locked_repository()
assert 3 == len(repository.packages) assert len(repository.packages) == 3
packages = repository.find_packages(get_dependency("a", "1.0")) packages = repository.find_packages(get_dependency("a", "1.0"))
assert len(packages) == 1 assert len(packages) == 1
...@@ -267,7 +267,7 @@ content-hash = "123456789" ...@@ -267,7 +267,7 @@ content-hash = "123456789"
locker.lock.write(tomlkit.parse(content)) locker.lock.write(tomlkit.parse(content))
repository = locker.locked_repository() repository = locker.locked_repository()
assert 2 == len(repository.packages) assert len(repository.packages) == 2
packages = repository.find_packages(get_dependency("a", "1.0")) packages = repository.find_packages(get_dependency("a", "1.0"))
assert len(packages) == 1 assert len(packages) == 1
...@@ -447,10 +447,10 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77 ...@@ -447,10 +447,10 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
_ = locker.lock_data _ = locker.lock_data
assert 1 == len(caplog.records) assert len(caplog.records) == 1
record = caplog.records[0] record = caplog.records[0]
assert "WARNING" == record.levelname assert record.levelname == "WARNING"
expected = """\ expected = """\
The lock file might not be compatible with the current version of Poetry. The lock file might not be compatible with the current version of Poetry.
...@@ -539,7 +539,7 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77 ...@@ -539,7 +539,7 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
_ = locker.lock_data _ = locker.lock_data
assert 0 == len(caplog.records) assert len(caplog.records) == 0
def test_locker_dumps_dependency_information_correctly( def test_locker_dumps_dependency_information_correctly(
......
...@@ -96,8 +96,8 @@ def test_load_plugins_and_activate( ...@@ -96,8 +96,8 @@ def test_load_plugins_and_activate(
manager.load_plugins() manager.load_plugins()
manager.activate(poetry, io) manager.activate(poetry, io)
assert "9.9.9" == poetry.package.version.text assert poetry.package.version.text == "9.9.9"
assert "Updating version\n" == io.fetch_output() assert io.fetch_output() == "Updating version\n"
def test_load_plugins_with_invalid_plugin( def test_load_plugins_with_invalid_plugin(
...@@ -136,5 +136,5 @@ def test_load_plugins_with_plugins_disabled( ...@@ -136,5 +136,5 @@ def test_load_plugins_with_plugins_disabled(
no_plugin_manager.load_plugins() no_plugin_manager.load_plugins()
assert "1.2.3" == poetry.package.version.text assert poetry.package.version.text == "1.2.3"
assert "" == io.fetch_output() assert io.fetch_output() == ""
...@@ -27,7 +27,7 @@ def test_uploader_properly_handles_400_errors(http, uploader): ...@@ -27,7 +27,7 @@ def test_uploader_properly_handles_400_errors(http, uploader):
with pytest.raises(UploadError) as e: with pytest.raises(UploadError) as e:
uploader.upload("https://foo.com") uploader.upload("https://foo.com")
assert "HTTP Error 400: Bad Request" == str(e.value) assert str(e.value) == "HTTP Error 400: Bad Request"
def test_uploader_properly_handles_403_errors(http, uploader): def test_uploader_properly_handles_403_errors(http, uploader):
...@@ -36,7 +36,7 @@ def test_uploader_properly_handles_403_errors(http, uploader): ...@@ -36,7 +36,7 @@ def test_uploader_properly_handles_403_errors(http, uploader):
with pytest.raises(UploadError) as e: with pytest.raises(UploadError) as e:
uploader.upload("https://foo.com") uploader.upload("https://foo.com")
assert "HTTP Error 403: Forbidden" == str(e.value) assert str(e.value) == "HTTP Error 403: Forbidden"
def test_uploader_properly_handles_301_redirects(http, uploader): def test_uploader_properly_handles_301_redirects(http, uploader):
...@@ -45,8 +45,9 @@ def test_uploader_properly_handles_301_redirects(http, uploader): ...@@ -45,8 +45,9 @@ def test_uploader_properly_handles_301_redirects(http, uploader):
with pytest.raises(UploadError) as e: with pytest.raises(UploadError) as e:
uploader.upload("https://foo.com") uploader.upload("https://foo.com")
assert "Redirects are not supported. Is the URL missing a trailing slash?" == str( assert (
e.value str(e.value)
== "Redirects are not supported. Is the URL missing a trailing slash?"
) )
...@@ -59,4 +60,4 @@ def test_uploader_registers_for_appropriate_400_errors(mocker, http, uploader): ...@@ -59,4 +60,4 @@ def test_uploader_registers_for_appropriate_400_errors(mocker, http, uploader):
with pytest.raises(UploadError): with pytest.raises(UploadError):
uploader.upload("https://foo.com") uploader.upload("https://foo.com")
assert 1 == register.call_count assert register.call_count == 1
...@@ -82,7 +82,7 @@ def check_solver_result(transaction, expected, synchronize=False): ...@@ -82,7 +82,7 @@ def check_solver_result(transaction, expected, synchronize=False):
result = [] result = []
ops = transaction.calculate_operations(synchronize=synchronize) ops = transaction.calculate_operations(synchronize=synchronize)
for op in ops: for op in ops:
if "update" == op.job_type: if op.job_type == "update":
result.append( result.append(
{ {
"job": "update", "job": "update",
...@@ -999,7 +999,7 @@ def test_solver_circular_dependency(solver, repo, package): ...@@ -999,7 +999,7 @@ def test_solver_circular_dependency(solver, repo, package):
], ],
) )
assert "main" == ops[0].package.category assert ops[0].package.category == "main"
def test_solver_circular_dependency_chain(solver, repo, package): def test_solver_circular_dependency_chain(solver, repo, package):
...@@ -1034,7 +1034,7 @@ def test_solver_circular_dependency_chain(solver, repo, package): ...@@ -1034,7 +1034,7 @@ def test_solver_circular_dependency_chain(solver, repo, package):
], ],
) )
assert "main" == ops[0].package.category assert ops[0].package.category == "main"
def test_solver_dense_dependencies(solver, repo, package): def test_solver_dense_dependencies(solver, repo, package):
...@@ -2123,7 +2123,7 @@ def test_solver_chooses_from_correct_repository_if_forced( ...@@ -2123,7 +2123,7 @@ def test_solver_chooses_from_correct_repository_if_forced(
], ],
) )
assert "http://legacy.foo.bar" == ops[0].package.source_url assert ops[0].package.source_url == "http://legacy.foo.bar"
def test_solver_chooses_from_correct_repository_if_forced_and_transitive_dependency( def test_solver_chooses_from_correct_repository_if_forced_and_transitive_dependency(
...@@ -2162,7 +2162,7 @@ def test_solver_chooses_from_correct_repository_if_forced_and_transitive_depende ...@@ -2162,7 +2162,7 @@ def test_solver_chooses_from_correct_repository_if_forced_and_transitive_depende
], ],
) )
assert "http://legacy.foo.bar" == ops[0].package.source_url assert ops[0].package.source_url == "http://legacy.foo.bar"
assert ops[1].package.source_type is None assert ops[1].package.source_type is None
assert ops[1].package.source_url is None assert ops[1].package.source_url is None
...@@ -2209,10 +2209,10 @@ def test_solver_does_not_choose_from_secondary_repository_by_default( ...@@ -2209,10 +2209,10 @@ def test_solver_does_not_choose_from_secondary_repository_by_default(
], ],
) )
assert "http://legacy.foo.bar" == ops[0].package.source_url assert ops[0].package.source_url == "http://legacy.foo.bar"
assert ops[1].package.source_type is None assert ops[1].package.source_type is None
assert ops[1].package.source_url is None assert ops[1].package.source_url is None
assert "http://legacy.foo.bar" == ops[2].package.source_url assert ops[2].package.source_url == "http://legacy.foo.bar"
def test_solver_chooses_from_secondary_if_explicit(package, installed, locked, io): def test_solver_chooses_from_secondary_if_explicit(package, installed, locked, io):
...@@ -2247,7 +2247,7 @@ def test_solver_chooses_from_secondary_if_explicit(package, installed, locked, i ...@@ -2247,7 +2247,7 @@ def test_solver_chooses_from_secondary_if_explicit(package, installed, locked, i
], ],
) )
assert "http://legacy.foo.bar" == ops[0].package.source_url assert ops[0].package.source_url == "http://legacy.foo.bar"
assert ops[1].package.source_type is None assert ops[1].package.source_type is None
assert ops[1].package.source_url is None assert ops[1].package.source_url is None
assert ops[2].package.source_type is None assert ops[2].package.source_type is None
......
...@@ -9,7 +9,7 @@ def check_operations(ops, expected): ...@@ -9,7 +9,7 @@ def check_operations(ops, expected):
result = [] result = []
for op in ops: for op in ops:
if "update" == op.job_type: if op.job_type == "update":
result.append( result.append(
{ {
"job": "update", "job": "update",
......
...@@ -106,7 +106,7 @@ def test_get_package_information_skips_dependencies_with_invalid_constraints(): ...@@ -106,7 +106,7 @@ def test_get_package_information_skips_dependencies_with_invalid_constraints():
package.description == "Python Language Server for the Language Server Protocol" package.description == "Python Language Server for the Language Server Protocol"
) )
assert 25 == len(package.requires) assert len(package.requires) == 25
assert sorted( assert sorted(
(r for r in package.requires if not r.is_optional()), key=lambda r: r.name (r for r in package.requires if not r.is_optional()), key=lambda r: r.name
) == [ ) == [
...@@ -202,10 +202,10 @@ def test_get_package_from_both_py2_and_py3_specific_wheels(): ...@@ -202,10 +202,10 @@ def test_get_package_from_both_py2_and_py3_specific_wheels():
package = repo.package("ipython", "5.7.0") package = repo.package("ipython", "5.7.0")
assert "ipython" == package.name assert package.name == "ipython"
assert "5.7.0" == package.version.text assert package.version.text == "5.7.0"
assert "*" == package.python_versions assert package.python_versions == "*"
assert 41 == len(package.requires) assert len(package.requires) == 41
expected = [ expected = [
Dependency("appnope", "*"), Dependency("appnope", "*"),
...@@ -225,14 +225,14 @@ def test_get_package_from_both_py2_and_py3_specific_wheels(): ...@@ -225,14 +225,14 @@ def test_get_package_from_both_py2_and_py3_specific_wheels():
required = [r for r in package.requires if not r.is_optional()] required = [r for r in package.requires if not r.is_optional()]
assert expected == required assert expected == required
assert 'python_version == "2.7"' == str(required[1].marker) assert str(required[1].marker) == 'python_version == "2.7"'
assert 'sys_platform == "win32" and python_version < "3.6"' == str( assert (
required[12].marker str(required[12].marker) == 'sys_platform == "win32" and python_version < "3.6"'
) )
assert 'python_version == "2.7" or python_version == "3.3"' == str( assert (
required[4].marker str(required[4].marker) == 'python_version == "2.7" or python_version == "3.3"'
) )
assert 'sys_platform != "win32"' == str(required[5].marker) assert str(required[5].marker) == 'sys_platform != "win32"'
def test_get_package_with_dist_and_universal_py3_wheel(): def test_get_package_with_dist_and_universal_py3_wheel():
...@@ -240,9 +240,9 @@ def test_get_package_with_dist_and_universal_py3_wheel(): ...@@ -240,9 +240,9 @@ def test_get_package_with_dist_and_universal_py3_wheel():
package = repo.package("ipython", "7.5.0") package = repo.package("ipython", "7.5.0")
assert "ipython" == package.name assert package.name == "ipython"
assert "7.5.0" == package.version.text assert package.version.text == "7.5.0"
assert ">=3.5" == package.python_versions assert package.python_versions == ">=3.5"
expected = [ expected = [
Dependency("appnope", "*"), Dependency("appnope", "*"),
......
...@@ -17,7 +17,7 @@ def test_pool_raises_package_not_found_when_no_package_is_found(): ...@@ -17,7 +17,7 @@ def test_pool_raises_package_not_found_when_no_package_is_found():
def test_pool(): def test_pool():
pool = Pool() pool = Pool()
assert 0 == len(pool.repositories) assert len(pool.repositories) == 0
assert not pool.has_default() assert not pool.has_default()
...@@ -25,7 +25,7 @@ def test_pool_with_initial_repositories(): ...@@ -25,7 +25,7 @@ def test_pool_with_initial_repositories():
repo = Repository() repo = Repository()
pool = Pool([repo]) pool = Pool([repo])
assert 1 == len(pool.repositories) assert len(pool.repositories) == 1
assert not pool.has_default() assert not pool.has_default()
......
...@@ -161,7 +161,7 @@ def test_pypi_repository_supports_reading_bz2_files(): ...@@ -161,7 +161,7 @@ def test_pypi_repository_supports_reading_bz2_files():
package = repo.package("twisted", "18.9.0") package = repo.package("twisted", "18.9.0")
assert package.name == "twisted" assert package.name == "twisted"
assert 71 == len(package.requires) assert len(package.requires) == 71
assert sorted( assert sorted(
(r for r in package.requires if not r.is_optional()), key=lambda r: r.name (r for r in package.requires if not r.is_optional()), key=lambda r: r.name
) == [ ) == [
...@@ -223,8 +223,8 @@ def test_get_should_invalid_cache_on_too_many_redirects_error(mocker): ...@@ -223,8 +223,8 @@ def test_get_should_invalid_cache_on_too_many_redirects_error(mocker):
def test_urls(): def test_urls():
repository = PyPiRepository() repository = PyPiRepository()
assert "https://pypi.org/simple/" == repository.url assert repository.url == "https://pypi.org/simple/"
assert "https://pypi.org/simple/" == repository.authenticated_url assert repository.authenticated_url == "https://pypi.org/simple/"
def test_use_pypi_pretty_name(): def test_use_pypi_pretty_name():
......
...@@ -156,7 +156,7 @@ def test_create_poetry_with_multi_constraints_dependency(): ...@@ -156,7 +156,7 @@ def test_create_poetry_with_multi_constraints_dependency():
def test_poetry_with_default_source(with_simple_keyring): def test_poetry_with_default_source(with_simple_keyring):
poetry = Factory().create_poetry(fixtures_dir / "with_default_source") poetry = Factory().create_poetry(fixtures_dir / "with_default_source")
assert 1 == len(poetry.pool.repositories) assert len(poetry.pool.repositories) == 1
def test_poetry_with_non_default_source(with_simple_keyring): def test_poetry_with_non_default_source(with_simple_keyring):
...@@ -246,7 +246,7 @@ def test_poetry_with_two_default_sources(with_simple_keyring): ...@@ -246,7 +246,7 @@ def test_poetry_with_two_default_sources(with_simple_keyring):
with pytest.raises(ValueError) as e: with pytest.raises(ValueError) as e:
Factory().create_poetry(fixtures_dir / "with_two_default_sources") Factory().create_poetry(fixtures_dir / "with_two_default_sources")
assert "Only one repository can be the default" == str(e.value) assert str(e.value) == "Only one repository can be the default"
def test_validate(): def test_validate():
...@@ -299,4 +299,4 @@ def test_create_poetry_with_plugins(mocker): ...@@ -299,4 +299,4 @@ def test_create_poetry_with_plugins(mocker):
poetry = Factory().create_poetry(fixtures_dir / "sample_project") poetry = Factory().create_poetry(fixtures_dir / "sample_project")
assert "9.9.9" == poetry.package.version.text assert poetry.package.version.text == "9.9.9"
...@@ -6,14 +6,15 @@ import pytest ...@@ -6,14 +6,15 @@ import pytest
import requests import requests
from cleo.io.null_io import NullIO from cleo.io.null_io import NullIO
from dataclasses import dataclass
from poetry.utils.authenticator import Authenticator from poetry.utils.authenticator import Authenticator
@dataclass
class SimpleCredential: class SimpleCredential:
def __init__(self, username, password): username: str
self.username = username password: str
self.password = password
@pytest.fixture() @pytest.fixture()
...@@ -37,7 +38,7 @@ def test_authenticator_uses_url_provided_credentials(config, mock_remote, http): ...@@ -37,7 +38,7 @@ def test_authenticator_uses_url_provided_credentials(config, mock_remote, http):
request = http.last_request() request = http.last_request()
assert "Basic Zm9vMDAxOmJhcjAwMg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic Zm9vMDAxOmJhcjAwMg=="
def test_authenticator_uses_credentials_from_config_if_not_provided( def test_authenticator_uses_credentials_from_config_if_not_provided(
...@@ -55,7 +56,7 @@ def test_authenticator_uses_credentials_from_config_if_not_provided( ...@@ -55,7 +56,7 @@ def test_authenticator_uses_credentials_from_config_if_not_provided(
request = http.last_request() request = http.last_request()
assert "Basic YmFyOmJheg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic YmFyOmJheg=="
def test_authenticator_uses_username_only_credentials( def test_authenticator_uses_username_only_credentials(
...@@ -73,7 +74,7 @@ def test_authenticator_uses_username_only_credentials( ...@@ -73,7 +74,7 @@ def test_authenticator_uses_username_only_credentials(
request = http.last_request() request = http.last_request()
assert "Basic Zm9vMDAxOg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic Zm9vMDAxOg=="
def test_authenticator_uses_password_only_credentials(config, mock_remote, http): def test_authenticator_uses_password_only_credentials(config, mock_remote, http):
...@@ -89,7 +90,7 @@ def test_authenticator_uses_password_only_credentials(config, mock_remote, http) ...@@ -89,7 +90,7 @@ def test_authenticator_uses_password_only_credentials(config, mock_remote, http)
request = http.last_request() request = http.last_request()
assert "Basic OmJhcjAwMg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic OmJhcjAwMg=="
def test_authenticator_uses_empty_strings_as_default_password( def test_authenticator_uses_empty_strings_as_default_password(
...@@ -107,7 +108,7 @@ def test_authenticator_uses_empty_strings_as_default_password( ...@@ -107,7 +108,7 @@ def test_authenticator_uses_empty_strings_as_default_password(
request = http.last_request() request = http.last_request()
assert "Basic YmFyOg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic YmFyOg=="
def test_authenticator_uses_empty_strings_as_default_username( def test_authenticator_uses_empty_strings_as_default_username(
...@@ -125,7 +126,7 @@ def test_authenticator_uses_empty_strings_as_default_username( ...@@ -125,7 +126,7 @@ def test_authenticator_uses_empty_strings_as_default_username(
request = http.last_request() request = http.last_request()
assert "Basic OmJhcg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic OmJhcg=="
def test_authenticator_falls_back_to_keyring_url( def test_authenticator_falls_back_to_keyring_url(
...@@ -146,7 +147,7 @@ def test_authenticator_falls_back_to_keyring_url( ...@@ -146,7 +147,7 @@ def test_authenticator_falls_back_to_keyring_url(
request = http.last_request() request = http.last_request()
assert "Basic OmJhcg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic OmJhcg=="
def test_authenticator_falls_back_to_keyring_netloc( def test_authenticator_falls_back_to_keyring_netloc(
...@@ -165,7 +166,7 @@ def test_authenticator_falls_back_to_keyring_netloc( ...@@ -165,7 +166,7 @@ def test_authenticator_falls_back_to_keyring_netloc(
request = http.last_request() request = http.last_request()
assert "Basic OmJhcg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic OmJhcg=="
@pytest.mark.filterwarnings("ignore::pytest.PytestUnhandledThreadExceptionWarning") @pytest.mark.filterwarnings("ignore::pytest.PytestUnhandledThreadExceptionWarning")
...@@ -250,4 +251,4 @@ def test_authenticator_uses_env_provided_credentials( ...@@ -250,4 +251,4 @@ def test_authenticator_uses_env_provided_credentials(
request = http.last_request() request = http.last_request()
assert "Basic YmFyOmJheg==" == request.headers["Authorization"] assert request.headers["Authorization"] == "Basic YmFyOmJheg=="
...@@ -516,7 +516,7 @@ def test_list(tmp_dir, manager, poetry, config): ...@@ -516,7 +516,7 @@ def test_list(tmp_dir, manager, poetry, config):
venvs = manager.list() venvs = manager.list()
assert 2 == len(venvs) assert len(venvs) == 2
assert (Path(tmp_dir) / f"{venv_name}-py3.6") == venvs[0].path assert (Path(tmp_dir) / f"{venv_name}-py3.6") == venvs[0].path
assert (Path(tmp_dir) / f"{venv_name}-py3.7") == venvs[1].path assert (Path(tmp_dir) / f"{venv_name}-py3.7") == venvs[1].path
...@@ -782,7 +782,7 @@ def test_create_venv_fails_if_no_compatible_python_version_could_be_found( ...@@ -782,7 +782,7 @@ def test_create_venv_fails_if_no_compatible_python_version_could_be_found(
) )
assert expected_message == str(e.value) assert expected_message == str(e.value)
assert 0 == m.call_count assert m.call_count == 0
def test_create_venv_does_not_try_to_find_compatible_versions_with_executable( def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
...@@ -808,7 +808,7 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable( ...@@ -808,7 +808,7 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
) )
assert expected_message == str(e.value) assert expected_message == str(e.value)
assert 0 == m.call_count assert m.call_count == 0
def test_create_venv_uses_patch_version_to_detect_compatibility( def test_create_venv_uses_patch_version_to_detect_compatibility(
......
...@@ -13,10 +13,10 @@ def test_set_http_password(config, with_simple_keyring, dummy_keyring): ...@@ -13,10 +13,10 @@ def test_set_http_password(config, with_simple_keyring, dummy_keyring):
assert manager.keyring.is_available() assert manager.keyring.is_available()
manager.set_http_password("foo", "bar", "baz") manager.set_http_password("foo", "bar", "baz")
assert "baz" == dummy_keyring.get_password("poetry-repository-foo", "bar") assert dummy_keyring.get_password("poetry-repository-foo", "bar") == "baz"
auth = config.get("http-basic.foo") auth = config.get("http-basic.foo")
assert "bar" == auth["username"] assert auth["username"] == "bar"
assert "password" not in auth assert "password" not in auth
...@@ -28,8 +28,8 @@ def test_get_http_auth(config, with_simple_keyring, dummy_keyring): ...@@ -28,8 +28,8 @@ def test_get_http_auth(config, with_simple_keyring, dummy_keyring):
assert manager.keyring.is_available() assert manager.keyring.is_available()
auth = manager.get_http_auth("foo") auth = manager.get_http_auth("foo")
assert "bar" == auth["username"] assert auth["username"] == "bar"
assert "baz" == auth["password"] assert auth["password"] == "baz"
def test_delete_http_password(config, with_simple_keyring, dummy_keyring): def test_delete_http_password(config, with_simple_keyring, dummy_keyring):
...@@ -52,7 +52,7 @@ def test_set_pypi_token(config, with_simple_keyring, dummy_keyring): ...@@ -52,7 +52,7 @@ def test_set_pypi_token(config, with_simple_keyring, dummy_keyring):
assert config.get("pypi-token.foo") is None assert config.get("pypi-token.foo") is None
assert "baz" == dummy_keyring.get_password("poetry-repository-foo", "__token__") assert dummy_keyring.get_password("poetry-repository-foo", "__token__") == "baz"
def test_get_pypi_token(config, with_simple_keyring, dummy_keyring): def test_get_pypi_token(config, with_simple_keyring, dummy_keyring):
...@@ -60,7 +60,7 @@ def test_get_pypi_token(config, with_simple_keyring, dummy_keyring): ...@@ -60,7 +60,7 @@ def test_get_pypi_token(config, with_simple_keyring, dummy_keyring):
manager = PasswordManager(config) manager = PasswordManager(config)
assert manager.keyring.is_available() assert manager.keyring.is_available()
assert "baz" == manager.get_pypi_token("foo") assert manager.get_pypi_token("foo") == "baz"
def test_delete_pypi_token(config, with_simple_keyring, dummy_keyring): def test_delete_pypi_token(config, with_simple_keyring, dummy_keyring):
...@@ -80,8 +80,8 @@ def test_set_http_password_with_unavailable_backend(config, with_fail_keyring): ...@@ -80,8 +80,8 @@ def test_set_http_password_with_unavailable_backend(config, with_fail_keyring):
manager.set_http_password("foo", "bar", "baz") manager.set_http_password("foo", "bar", "baz")
auth = config.get("http-basic.foo") auth = config.get("http-basic.foo")
assert "bar" == auth["username"] assert auth["username"] == "bar"
assert "baz" == auth["password"] assert auth["password"] == "baz"
def test_get_http_auth_with_unavailable_backend(config, with_fail_keyring): def test_get_http_auth_with_unavailable_backend(config, with_fail_keyring):
...@@ -93,8 +93,8 @@ def test_get_http_auth_with_unavailable_backend(config, with_fail_keyring): ...@@ -93,8 +93,8 @@ def test_get_http_auth_with_unavailable_backend(config, with_fail_keyring):
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 "bar" == auth["username"] assert auth["username"] == "bar"
assert "baz" == auth["password"] assert auth["password"] == "baz"
def test_delete_http_password_with_unavailable_backend(config, with_fail_keyring): def test_delete_http_password_with_unavailable_backend(config, with_fail_keyring):
...@@ -115,7 +115,7 @@ def test_set_pypi_token_with_unavailable_backend(config, with_fail_keyring): ...@@ -115,7 +115,7 @@ def test_set_pypi_token_with_unavailable_backend(config, with_fail_keyring):
assert not manager.keyring.is_available() assert not manager.keyring.is_available()
manager.set_pypi_token("foo", "baz") manager.set_pypi_token("foo", "baz")
assert "baz" == config.get("pypi-token.foo") assert config.get("pypi-token.foo") == "baz"
def test_get_pypi_token_with_unavailable_backend(config, with_fail_keyring): def test_get_pypi_token_with_unavailable_backend(config, with_fail_keyring):
...@@ -123,7 +123,7 @@ def test_get_pypi_token_with_unavailable_backend(config, with_fail_keyring): ...@@ -123,7 +123,7 @@ def test_get_pypi_token_with_unavailable_backend(config, with_fail_keyring):
manager = PasswordManager(config) manager = PasswordManager(config)
assert not manager.keyring.is_available() assert not manager.keyring.is_available()
assert "baz" == manager.get_pypi_token("foo") assert manager.get_pypi_token("foo") == "baz"
def test_delete_pypi_token_with_unavailable_backend(config, with_fail_keyring): def test_delete_pypi_token_with_unavailable_backend(config, with_fail_keyring):
...@@ -166,5 +166,5 @@ def test_get_http_auth_from_environment_variables(environ, config, with_simple_k ...@@ -166,5 +166,5 @@ def test_get_http_auth_from_environment_variables(environ, config, with_simple_k
auth = manager.get_http_auth("foo") auth = manager.get_http_auth("foo")
assert "bar" == auth["username"] assert auth["username"] == "bar"
assert "baz" == auth["password"] assert auth["password"] == "baz"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment