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 =
E501,
# E203: Whitespace before ':' (pycqa/pycodestyle#373)
E203,
# SIM106: Handle error-cases first
SIM106,
per-file-ignores =
# F401: Module imported by unused (non-implicit modules)
# TC002: Move third-party import '...' into a type-checking block
......
......@@ -36,6 +36,7 @@ repos:
- flake8-comprehensions==3.7.0
- flake8-no-pep420==1.2.0
- flake8-quotes==3.3.1
- flake8-simplify==0.14.2
- flake8-tidy-imports==4.5.0
- flake8-type-checking==1.1.0
- flake8-typing-imports==1.11.0
......
......@@ -125,8 +125,8 @@ def is_decorated():
if platform.system().lower() == "windows":
return (
os.getenv("ANSICON") is not None
or "ON" == os.getenv("ConEmuANSI")
or "xterm" == os.getenv("Term")
or os.getenv("ConEmuANSI") == "ON"
or os.getenv("Term") == "xterm"
)
if not hasattr(sys.stdout, "fileno"):
......
......@@ -96,8 +96,8 @@ def is_decorated():
if WINDOWS:
return (
os.getenv("ANSICON") is not None
or "ON" == os.getenv("ConEmuANSI")
or "xterm" == os.getenv("Term")
or os.getenv("ConEmuANSI") == "ON"
or os.getenv("Term") == "xterm"
)
if not hasattr(sys.stdout, "fileno"):
......
import logging
import re
from contextlib import suppress
from importlib import import_module
from typing import TYPE_CHECKING
from typing import Any
......@@ -195,10 +196,8 @@ class Application(BaseApplication):
# We need to check if the command being run
# is the "run" command.
definition = self.definition
try:
with suppress(CleoException):
io.input.bind(definition)
except CleoException:
pass
name = io.input.first_argument
if name == "run":
......@@ -218,10 +217,8 @@ class Application(BaseApplication):
for shortcut in shortcuts:
run_input.add_parameter_option("-" + shortcut.lstrip("-"))
try:
with suppress(CleoException):
run_input.bind(definition)
except CleoException:
pass
for option_name, value in input.options.items():
if value:
......
import sys
from contextlib import suppress
from cleo.helpers import argument
from cleo.helpers import option
......@@ -44,13 +46,11 @@ class NewCommand(Command):
if not name:
name = path.name
if path.exists():
if list(path.glob("*")):
# Directory is not empty. Aborting.
raise RuntimeError(
"Destination <fg=yellow>{}</> "
"exists and is not empty".format(path)
)
if path.exists() and list(path.glob("*")):
# Directory is not empty. Aborting.
raise RuntimeError(
"Destination <fg=yellow>{}</> " "exists and is not empty".format(path)
)
readme_format = self.option("readme") or "md"
......@@ -78,10 +78,8 @@ class NewCommand(Command):
path = path.resolve()
try:
with suppress(ValueError):
path = path.relative_to(Path.cwd())
except ValueError:
pass
self.line(
"Created package <info>{}</> in <fg=blue>{}</>".format(
......
......@@ -48,14 +48,13 @@ the config command.
# Building package first, if told
if self.option("build"):
if publisher.files:
if not self.confirm(
"There are <info>{}</info> files ready for publishing. "
"Build anyway?".format(len(publisher.files))
):
self.line_error("<error>Aborted!</error>")
return 1
if publisher.files and not self.confirm(
"There are <info>{}</info> files ready for publishing. "
"Build anyway?".format(len(publisher.files))
):
self.line_error("<error>Aborted!</error>")
return 1
self.call("build")
......
......@@ -359,11 +359,9 @@ lists all packages available."""
dependencies = package.requires
dependencies = sorted(dependencies, key=lambda x: x.name)
tree_bar = "├"
j = 0
total = len(dependencies)
for dependency in dependencies:
j += 1
if j == total:
for i, dependency in enumerate(dependencies, 1):
if i == total:
tree_bar = "└"
level = 1
......@@ -403,10 +401,8 @@ lists all packages available."""
dependencies = sorted(dependencies, key=lambda x: x.name)
tree_bar = previous_tree_bar + " ├"
i = 0
total = len(dependencies)
for dependency in dependencies:
i += 1
for i, dependency in enumerate(dependencies, 1):
current_tree = packages_in_tree
if i == total:
tree_bar = previous_tree_bar + " └"
......
......@@ -60,9 +60,8 @@ class Factory(BaseFactory):
for source in base_poetry.pyproject.poetry_config.get("source", []):
name = source.get("name")
url = source.get("url")
if name and url:
if name not in existing_repositories:
repositories[name] = {"url": url}
if name and url and name not in existing_repositories:
repositories[name] = {"url": url}
config.merge({"repositories": repositories})
......
......@@ -211,15 +211,16 @@ class Executor:
def _execute_operation(self, operation: "OperationTypes") -> None:
try:
if self.supports_fancy_output():
if id(operation) not in self._sections:
if self._should_write_operation(operation):
with self._lock:
self._sections[id(operation)] = self._io.section()
self._sections[id(operation)].write_line(
" <fg=blue;options=bold>•</> {message}: <fg=blue>Pending...</>".format(
message=self.get_operation_message(operation),
),
)
if id(operation) not in self._sections and self._should_write_operation(
operation
):
with self._lock:
self._sections[id(operation)] = self._io.section()
self._sections[id(operation)].write_line(
" <fg=blue;options=bold>•</> {message}: <fg=blue>Pending...</>".format(
message=self.get_operation_message(operation),
),
)
else:
if self._should_write_operation(operation):
if not operation.skipped:
......
......@@ -569,9 +569,8 @@ class Installer:
# If a package is optional and not requested
# in any extra we skip it
if package.optional:
if package.name not in extra_packages:
op.skip("Not required")
if package.optional and package.name not in extra_packages:
op.skip("Not required")
def _get_extra_packages(self, repo: Repository) -> List[str]:
"""
......
......@@ -66,12 +66,14 @@ class PipInstaller(BaseInstaller):
index_url = repository.authenticated_url
args += ["--index-url", index_url]
if self._pool.has_default():
if repository.name != self._pool.repositories[0].name:
args += [
"--extra-index-url",
self._pool.repositories[0].authenticated_url,
]
if (
self._pool.has_default()
and repository.name != self._pool.repositories[0].name
):
args += [
"--extra-index-url",
self._pool.repositories[0].authenticated_url,
]
if update:
args.append("-U")
......
......@@ -507,12 +507,14 @@ class Provider:
if self._env and not dep.marker.validate(self._env.marker_env):
continue
if not package.is_root():
if (dep.is_optional() and dep.name not in optional_dependencies) or (
if not package.is_root() and (
(dep.is_optional() and dep.name not in optional_dependencies)
or (
dep.in_extras
and not set(dep.in_extras).intersection(package.dependency.extras)
):
continue
)
):
continue
_dependencies.append(dep)
......
......@@ -42,14 +42,13 @@ class Transaction:
if result_package.name == installed_package.name:
installed = True
if result_package.version != installed_package.version:
operations.append(
Update(installed_package, result_package, priority=priority)
if result_package.version != installed_package.version or (
(
installed_package.source_type
or result_package.source_type != "legacy"
)
elif (
installed_package.source_type
or result_package.source_type != "legacy"
) and not result_package.is_same_package_as(installed_package):
and not result_package.is_same_package_as(installed_package)
):
operations.append(
Update(installed_package, result_package, priority=priority)
)
......
......@@ -237,14 +237,13 @@ class LegacyRepository(PyPiRepository):
constraint = parse_constraint(constraint)
allow_prereleases = dependency.allows_prereleases()
if isinstance(constraint, VersionRange):
if (
constraint.max is not None
and constraint.max.is_unstable()
or constraint.min is not None
and constraint.min.is_unstable()
):
allow_prereleases = True
if isinstance(constraint, VersionRange) and (
constraint.max is not None
and constraint.max.is_unstable()
or constraint.min is not None
and constraint.min.is_unstable()
):
allow_prereleases = True
key = dependency.name
if not constraint.is_any():
......
from contextlib import suppress
from typing import TYPE_CHECKING
from typing import Dict
from typing import List
......@@ -135,10 +136,8 @@ class Pool(BaseRepository):
raise ValueError(f'Repository "{repository}" does not exist.')
if repository is not None and not self._ignore_repository_names:
try:
with suppress(PackageNotFound):
return self.repository(repository).package(name, version, extras=extras)
except PackageNotFound:
pass
else:
for repo in self._repositories:
try:
......
......@@ -97,14 +97,13 @@ class PyPiRepository(RemoteRepository):
constraint = parse_constraint(constraint)
allow_prereleases = dependency.allows_prereleases()
if isinstance(constraint, VersionRange):
if (
constraint.max is not None
and constraint.max.is_unstable()
or constraint.min is not None
and constraint.min.is_unstable()
):
allow_prereleases = True
if isinstance(constraint, VersionRange) and (
constraint.max is not None
and constraint.max.is_unstable()
or constraint.min is not None
and constraint.min.is_unstable()
):
allow_prereleases = True
try:
info = self.get_package_info(dependency.name)
......
......@@ -52,14 +52,13 @@ class Repository(BaseRepository):
constraint = parse_constraint(constraint)
allow_prereleases = dependency.allows_prereleases()
if isinstance(constraint, VersionRange):
if (
constraint.max is not None
and constraint.max.is_unstable()
or constraint.min is not None
and constraint.min.is_unstable()
):
allow_prereleases = True
if isinstance(constraint, VersionRange) and (
constraint.max is not None
and constraint.max.is_unstable()
or constraint.min is not None
and constraint.min.is_unstable()
):
allow_prereleases = True
for package in self.packages:
if dependency.name == package.name:
......@@ -85,12 +84,9 @@ class Repository(BaseRepository):
def has_package(self, package: "Package") -> bool:
package_id = package.unique_name
for repo_package in self.packages:
if package_id == repo_package.unique_name:
return True
return False
return any(
package_id == repo_package.unique_name for repo_package in self.packages
)
def add_package(self, package: "Package") -> None:
self._packages.append(package)
......
import sys
from contextlib import suppress
from typing import List
from typing import Optional
......@@ -20,10 +21,8 @@ def decode(string: str, encodings: Optional[List[str]] = None) -> str:
encodings = encodings or ["utf-8", "latin1", "ascii"]
for encoding in encodings:
try:
with suppress(UnicodeEncodeError, UnicodeDecodeError):
return string.decode(encoding)
except (UnicodeEncodeError, UnicodeDecodeError):
pass
return string.decode(encodings[0], errors="ignore")
......@@ -35,10 +34,8 @@ def encode(string: str, encodings: Optional[List[str]] = None) -> bytes:
encodings = encodings or ["utf-8", "latin1", "ascii"]
for encoding in encodings:
try:
with suppress(UnicodeEncodeError, UnicodeDecodeError):
return string.encode(encoding)
except (UnicodeEncodeError, UnicodeDecodeError):
pass
return string.encode(encodings[0], errors="ignore")
......
......@@ -615,11 +615,14 @@ class EnvManager:
if not in_venv or env is not None:
# Checking if a local virtualenv exists
if self._poetry.config.get("virtualenvs.in-project") is not False:
if (cwd / ".venv").exists() and (cwd / ".venv").is_dir():
venv = cwd / ".venv"
if (
self._poetry.config.get("virtualenvs.in-project") is not False
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)
......@@ -1214,7 +1217,7 @@ class Env:
self.purelib,
self.platlib,
fallbacks,
skip_write_checks=False if fallbacks else True,
skip_write_checks=not fallbacks,
)
return self._site_packages
......
......@@ -93,11 +93,10 @@ class Exporter:
else:
line = f"{package.name}=={package.version}"
if not is_direct_remote_reference:
if ";" in requirement:
markers = requirement.split(";", 1)[1].strip()
if markers:
line += f" ; {markers}"
if not is_direct_remote_reference and ";" in requirement:
markers = requirement.split(";", 1)[1].strip()
if markers:
line += f" ; {markers}"
if (
not is_direct_remote_reference
......
import logging
from contextlib import suppress
from typing import TYPE_CHECKING
from typing import Dict
from typing import Optional
......@@ -185,9 +186,7 @@ class PasswordManager:
if not auth or "username" not in auth:
return
try:
with suppress(KeyRingError):
self.keyring.delete_password(name, auth["username"])
except KeyRingError:
pass
self._config.auth_config_source.remove_property(f"http-basic.{name}")
......@@ -99,11 +99,9 @@ class Shell:
sys.exit(c.exitstatus)
def _get_activate_script(self) -> str:
if "fish" == self._name:
if self._name == "fish":
suffix = ".fish"
elif "csh" == self._name:
suffix = ".csh"
elif "tcsh" == self._name:
elif self._name in ("csh", "tcsh"):
suffix = ".csh"
else:
suffix = ""
......@@ -111,13 +109,8 @@ class Shell:
return "activate" + suffix
def _get_source_command(self) -> str:
if "fish" == self._name:
return "source"
elif "csh" == self._name:
if self._name in ("fish", "csh", "tcsh"):
return "source"
elif "tcsh" == self._name:
return "source"
return "."
def __repr__(self) -> str:
......
......@@ -4,6 +4,7 @@ import shutil
import sys
import tempfile
from contextlib import suppress
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
......@@ -188,10 +189,8 @@ def download_mock(mocker):
def pep517_metadata_mock(mocker):
@classmethod
def _pep517_metadata(cls, path):
try:
with suppress(PackageInfoError):
return PackageInfo.from_setup_files(path)
except PackageInfoError:
pass
return PackageInfo(name="demo", version="0.1.2")
mocker.patch(
......
......@@ -60,5 +60,5 @@ Executable: {base_executable}
def test_env_info_displays_path_only(tester: "CommandTester"):
tester.execute("--path")
expected = str(Path("/prefix"))
assert expected + "\n" == tester.io.fetch_output()
expected = str(Path("/prefix")) + "\n"
assert tester.io.fetch_output() == expected
......@@ -58,7 +58,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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"]
......@@ -80,9 +80,9 @@ Failed to add packages. Only vcs/path dependencies support editable installs. ca
No changes were applied.
"""
assert 1 == tester.status_code
assert tester.status_code == 1
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"]
......@@ -107,7 +107,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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(
......@@ -131,7 +131,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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(
......@@ -162,7 +162,7 @@ Package operations: 2 installs, 0 updates, 0 removals
"""
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(
......@@ -192,7 +192,7 @@ Package operations: 2 installs, 0 updates, 0 removals
"""
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(
......@@ -222,7 +222,7 @@ Package operations: 2 installs, 0 updates, 0 removals
"""
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"]
......@@ -258,7 +258,7 @@ Package operations: 2 installs, 0 updates, 0 removals
"""
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(
......@@ -291,7 +291,7 @@ Package operations: 4 installs, 0 updates, 0 removals
"""
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"]
......@@ -332,7 +332,7 @@ Package operations: 2 installs, 0 updates, 0 removals
"""
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"]
......@@ -381,7 +381,7 @@ Package operations: 2 installs, 0 updates, 0 removals
)
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"]
......@@ -424,7 +424,7 @@ Package operations: 2 installs, 0 updates, 0 removals
)
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(
......@@ -458,7 +458,7 @@ Package operations: 2 installs, 0 updates, 0 removals
)
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"]
......@@ -498,7 +498,7 @@ Package operations: 2 installs, 0 updates, 0 removals
)
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"]
......@@ -536,7 +536,7 @@ Package operations: 2 installs, 0 updates, 0 removals
"""
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"]
......@@ -576,7 +576,7 @@ Package operations: 2 installs, 0 updates, 0 removals
"""
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"]
......@@ -618,7 +618,7 @@ Package operations: 4 installs, 0 updates, 0 removals
expected = set(expected.splitlines())
output = set(tester.io.fetch_output().splitlines())
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"]
......@@ -652,7 +652,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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"]
......@@ -689,7 +689,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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"]
......@@ -724,7 +724,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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"]
......@@ -741,7 +741,7 @@ def test_add_constraint_with_source_that_does_not_exist(
with pytest.raises(ValueError) as e:
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(
......@@ -761,7 +761,7 @@ def test_add_constraint_not_found_with_source(
with pytest.raises(ValueError) as e:
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(
......@@ -786,7 +786,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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"]
......@@ -827,7 +827,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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"]
......@@ -857,7 +857,7 @@ Package operations: 1 install, 0 updates, 0 removals
"""
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"]
......@@ -1696,7 +1696,7 @@ def test_add_constraint_with_source_that_does_not_exist_old_installer(
with pytest.raises(ValueError) as e:
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(
......@@ -1716,7 +1716,7 @@ def test_add_constraint_not_found_with_source_old_installer(
with pytest.raises(ValueError) as e:
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(
......
......@@ -36,7 +36,7 @@ def test_show_config_with_local_config_file_empty(
)
tester.execute()
assert "" == tester.io.fetch_output()
assert tester.io.fetch_output() == ""
def test_list_displays_default_value_if_not_set(
......@@ -82,7 +82,7 @@ virtualenvs.path = {path} # {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()
......@@ -130,7 +130,7 @@ virtualenvs.path = {path} # {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()
......@@ -140,7 +140,7 @@ def test_set_pypi_token(
tester.execute("pypi-token.pypi mytoken")
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(
......@@ -153,8 +153,8 @@ def test_set_client_cert(
tester.execute("certificates.foo.client-cert path/to/cert.pem")
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(
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(
......
......@@ -112,7 +112,7 @@ def test_noninteractive(
expected = "Using version ^3.6.0 for pytest\n"
assert tester.io.fetch_output() == expected
assert "" == tester.io.fetch_error()
assert tester.io.fetch_error() == ""
toml_content = (tmp_path / "pyproject.toml").read_text()
assert 'name = "my-package"' in toml_content
......
......@@ -29,7 +29,7 @@ def test_publish_returns_non_zero_code_for_upload_errors(
exit_code = app_tester.execute("publish --username foo --password bar")
assert 1 == exit_code
assert exit_code == 1
expected_output = """
Publishing simple-project (1.2.3) to PyPI
......@@ -59,7 +59,7 @@ def test_publish_returns_non_zero_code_for_connection_errors(
exit_code = app_tester.execute("publish --username foo --password bar")
assert 1 == exit_code
assert exit_code == 1
expected = str(UploadError(error=requests.ConnectionError()))
......@@ -96,7 +96,7 @@ def test_publish_dry_run(
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()
error = app_tester.io.fetch_error()
......
......@@ -55,19 +55,19 @@ def test_increment_version(
def test_version_show(tester: "CommandTester"):
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"):
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"):
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"):
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"):
tester.execute("")
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"):
......@@ -65,7 +65,7 @@ def test_application_with_plugins_disabled(mocker: "MockerFixture"):
tester.execute("--no-plugins")
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"):
......@@ -83,8 +83,8 @@ def test_application_execute_plugin_command(mocker: "MockerFixture"):
tester = ApplicationTester(app)
tester.execute("foo")
assert "foo called\n" == tester.io.fetch_output()
assert 0 == tester.status_code
assert tester.io.fetch_output() == "foo called\n"
assert tester.status_code == 0
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.execute("foo --no-plugins")
assert "" == tester.io.fetch_output()
assert '\nThe command "foo" does not exist.\n' == tester.io.fetch_error()
assert 1 == tester.status_code
assert tester.io.fetch_output() == ""
assert tester.io.fetch_error() == '\nThe command "foo" does not exist.\n'
assert tester.status_code == 1
......@@ -121,7 +121,7 @@ def test_chooser_chooses_universal_wheel_link_if_available(
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"])
......@@ -142,7 +142,7 @@ def test_chooser_chooses_specific_python_universal_wheel_link_if_available(
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"])
......@@ -166,7 +166,7 @@ def test_chooser_chooses_system_specific_wheel_link_if_available(
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"])
......@@ -191,7 +191,7 @@ def test_chooser_chooses_sdist_if_no_compatible_wheel_link_is_available(
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"])
......@@ -224,7 +224,7 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes(
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"])
......
......@@ -178,8 +178,8 @@ Package operations: 4 installs, 1 update, 1 removal
expected = set(expected.splitlines())
output = set(io.fetch_output().splitlines())
assert expected == output
assert 5 == len(env.executed)
assert 0 == return_code
assert len(env.executed) == 5
assert return_code == 0
pip_editable_install.assert_called_once()
......@@ -192,8 +192,11 @@ def test_execute_shows_skipped_operations_if_verbose(
executor = Executor(env, pool, config, io)
executor.verbose()
assert 0 == executor.execute(
[Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed")]
assert (
executor.execute(
[Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed")]
)
== 0
)
expected = """
......@@ -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
"""
assert expected == io.fetch_output()
assert 0 == len(env.executed)
assert len(env.executed) == 0
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!"))
assert 1 == executor.execute([Install(Package("clikit", "0.2.3"))])
assert executor.execute([Install(Package("clikit", "0.2.3"))]) == 1
expected = """
Package operations: 1 install, 0 updates, 0 removals
......@@ -265,7 +268,7 @@ def test_execute_works_with_ansi_output(
for line in expected:
assert line in output
assert 0 == return_code
assert return_code == 0
def test_execute_works_with_no_ansi_output(
......@@ -301,7 +304,7 @@ Package operations: 1 install, 0 updates, 0 removals
expected = set(expected.splitlines())
output = set(io_not_decorated.fetch_output().splitlines())
assert expected == output
assert 0 == return_code
assert return_code == 0
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
# A return code of -2 means KeyboardInterrupt in the pip subprocess
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 = """
Package operations: 1 install, 0 updates, 0 removals
......@@ -340,7 +343,7 @@ def test_execute_should_gracefully_handle_io_error(
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"""
Package operations: 1 install, 0 updates, 0 removals
......
......@@ -1888,7 +1888,7 @@ def test_installer_can_handle_old_lock_files(
installer.run()
assert 6 == len(installer.installer.installs)
assert len(installer.installer.installs) == 6
installer = Installer(
NullIO(),
......@@ -1903,7 +1903,7 @@ def test_installer_can_handle_old_lock_files(
installer.run()
# funcsigs will be added
assert 7 == len(installer.installer.installs)
assert len(installer.installer.installs) == 7
installer = Installer(
NullIO(),
......@@ -1918,4 +1918,4 @@ def test_installer_can_handle_old_lock_files(
installer.run()
# 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(
assert dist_info.joinpath("RECORD").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 (
"[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 = """\
......
......@@ -140,11 +140,11 @@ cachecontrol = []
packages = locker.locked_repository().packages
assert 1 == len(packages)
assert len(packages) == 1
package = packages[0]
assert 3 == len(package.requires)
assert 2 == len(package.extras)
assert len(package.requires) == 3
assert len(package.extras) == 2
lockfile_dep = package.extras["filecache"][0]
assert lockfile_dep.name == "lockfile"
......@@ -202,7 +202,7 @@ content-hash = "123456789"
locker.lock.write(tomlkit.parse(content))
repository = locker.locked_repository()
assert 3 == len(repository.packages)
assert len(repository.packages) == 3
packages = repository.find_packages(get_dependency("a", "1.0"))
assert len(packages) == 1
......@@ -267,7 +267,7 @@ content-hash = "123456789"
locker.lock.write(tomlkit.parse(content))
repository = locker.locked_repository()
assert 2 == len(repository.packages)
assert len(repository.packages) == 2
packages = repository.find_packages(get_dependency("a", "1.0"))
assert len(packages) == 1
......@@ -447,10 +447,10 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
_ = locker.lock_data
assert 1 == len(caplog.records)
assert len(caplog.records) == 1
record = caplog.records[0]
assert "WARNING" == record.levelname
assert record.levelname == "WARNING"
expected = """\
The lock file might not be compatible with the current version of Poetry.
......@@ -539,7 +539,7 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
_ = locker.lock_data
assert 0 == len(caplog.records)
assert len(caplog.records) == 0
def test_locker_dumps_dependency_information_correctly(
......
......@@ -96,8 +96,8 @@ def test_load_plugins_and_activate(
manager.load_plugins()
manager.activate(poetry, io)
assert "9.9.9" == poetry.package.version.text
assert "Updating version\n" == io.fetch_output()
assert poetry.package.version.text == "9.9.9"
assert io.fetch_output() == "Updating version\n"
def test_load_plugins_with_invalid_plugin(
......@@ -136,5 +136,5 @@ def test_load_plugins_with_plugins_disabled(
no_plugin_manager.load_plugins()
assert "1.2.3" == poetry.package.version.text
assert "" == io.fetch_output()
assert poetry.package.version.text == "1.2.3"
assert io.fetch_output() == ""
......@@ -27,7 +27,7 @@ def test_uploader_properly_handles_400_errors(http, uploader):
with pytest.raises(UploadError) as e:
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):
......@@ -36,7 +36,7 @@ def test_uploader_properly_handles_403_errors(http, uploader):
with pytest.raises(UploadError) as e:
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):
......@@ -45,8 +45,9 @@ def test_uploader_properly_handles_301_redirects(http, uploader):
with pytest.raises(UploadError) as e:
uploader.upload("https://foo.com")
assert "Redirects are not supported. Is the URL missing a trailing slash?" == str(
e.value
assert (
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):
with pytest.raises(UploadError):
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):
result = []
ops = transaction.calculate_operations(synchronize=synchronize)
for op in ops:
if "update" == op.job_type:
if op.job_type == "update":
result.append(
{
"job": "update",
......@@ -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):
......@@ -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):
......@@ -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(
......@@ -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_url is None
......@@ -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_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):
......@@ -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_url is None
assert ops[2].package.source_type is None
......
......@@ -9,7 +9,7 @@ def check_operations(ops, expected):
result = []
for op in ops:
if "update" == op.job_type:
if op.job_type == "update":
result.append(
{
"job": "update",
......
......@@ -106,7 +106,7 @@ def test_get_package_information_skips_dependencies_with_invalid_constraints():
package.description == "Python Language Server for the Language Server Protocol"
)
assert 25 == len(package.requires)
assert len(package.requires) == 25
assert sorted(
(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():
package = repo.package("ipython", "5.7.0")
assert "ipython" == package.name
assert "5.7.0" == package.version.text
assert "*" == package.python_versions
assert 41 == len(package.requires)
assert package.name == "ipython"
assert package.version.text == "5.7.0"
assert package.python_versions == "*"
assert len(package.requires) == 41
expected = [
Dependency("appnope", "*"),
......@@ -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()]
assert expected == required
assert 'python_version == "2.7"' == str(required[1].marker)
assert 'sys_platform == "win32" and python_version < "3.6"' == str(
required[12].marker
assert str(required[1].marker) == 'python_version == "2.7"'
assert (
str(required[12].marker) == 'sys_platform == "win32" and python_version < "3.6"'
)
assert 'python_version == "2.7" or python_version == "3.3"' == str(
required[4].marker
assert (
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():
......@@ -240,9 +240,9 @@ def test_get_package_with_dist_and_universal_py3_wheel():
package = repo.package("ipython", "7.5.0")
assert "ipython" == package.name
assert "7.5.0" == package.version.text
assert ">=3.5" == package.python_versions
assert package.name == "ipython"
assert package.version.text == "7.5.0"
assert package.python_versions == ">=3.5"
expected = [
Dependency("appnope", "*"),
......
......@@ -17,7 +17,7 @@ def test_pool_raises_package_not_found_when_no_package_is_found():
def test_pool():
pool = Pool()
assert 0 == len(pool.repositories)
assert len(pool.repositories) == 0
assert not pool.has_default()
......@@ -25,7 +25,7 @@ def test_pool_with_initial_repositories():
repo = Repository()
pool = Pool([repo])
assert 1 == len(pool.repositories)
assert len(pool.repositories) == 1
assert not pool.has_default()
......
......@@ -161,7 +161,7 @@ def test_pypi_repository_supports_reading_bz2_files():
package = repo.package("twisted", "18.9.0")
assert package.name == "twisted"
assert 71 == len(package.requires)
assert len(package.requires) == 71
assert sorted(
(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):
def test_urls():
repository = PyPiRepository()
assert "https://pypi.org/simple/" == repository.url
assert "https://pypi.org/simple/" == repository.authenticated_url
assert repository.url == "https://pypi.org/simple/"
assert repository.authenticated_url == "https://pypi.org/simple/"
def test_use_pypi_pretty_name():
......
......@@ -156,7 +156,7 @@ def test_create_poetry_with_multi_constraints_dependency():
def test_poetry_with_default_source(with_simple_keyring):
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):
......@@ -246,7 +246,7 @@ def test_poetry_with_two_default_sources(with_simple_keyring):
with pytest.raises(ValueError) as e:
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():
......@@ -299,4 +299,4 @@ def test_create_poetry_with_plugins(mocker):
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
import requests
from cleo.io.null_io import NullIO
from dataclasses import dataclass
from poetry.utils.authenticator import Authenticator
@dataclass
class SimpleCredential:
def __init__(self, username, password):
self.username = username
self.password = password
username: str
password: str
@pytest.fixture()
......@@ -37,7 +38,7 @@ def test_authenticator_uses_url_provided_credentials(config, mock_remote, http):
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(
......@@ -55,7 +56,7 @@ def test_authenticator_uses_credentials_from_config_if_not_provided(
request = http.last_request()
assert "Basic YmFyOmJheg==" == request.headers["Authorization"]
assert request.headers["Authorization"] == "Basic YmFyOmJheg=="
def test_authenticator_uses_username_only_credentials(
......@@ -73,7 +74,7 @@ def test_authenticator_uses_username_only_credentials(
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):
......@@ -89,7 +90,7 @@ def test_authenticator_uses_password_only_credentials(config, mock_remote, http)
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(
......@@ -107,7 +108,7 @@ def test_authenticator_uses_empty_strings_as_default_password(
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(
......@@ -125,7 +126,7 @@ def test_authenticator_uses_empty_strings_as_default_username(
request = http.last_request()
assert "Basic OmJhcg==" == request.headers["Authorization"]
assert request.headers["Authorization"] == "Basic OmJhcg=="
def test_authenticator_falls_back_to_keyring_url(
......@@ -146,7 +147,7 @@ def test_authenticator_falls_back_to_keyring_url(
request = http.last_request()
assert "Basic OmJhcg==" == request.headers["Authorization"]
assert request.headers["Authorization"] == "Basic OmJhcg=="
def test_authenticator_falls_back_to_keyring_netloc(
......@@ -165,7 +166,7 @@ def test_authenticator_falls_back_to_keyring_netloc(
request = http.last_request()
assert "Basic OmJhcg==" == request.headers["Authorization"]
assert request.headers["Authorization"] == "Basic OmJhcg=="
@pytest.mark.filterwarnings("ignore::pytest.PytestUnhandledThreadExceptionWarning")
......@@ -250,4 +251,4 @@ def test_authenticator_uses_env_provided_credentials(
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):
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.7") == venvs[1].path
......@@ -782,7 +782,7 @@ def test_create_venv_fails_if_no_compatible_python_version_could_be_found(
)
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(
......@@ -808,7 +808,7 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
)
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(
......
......@@ -13,10 +13,10 @@ def test_set_http_password(config, with_simple_keyring, dummy_keyring):
assert manager.keyring.is_available()
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")
assert "bar" == auth["username"]
assert auth["username"] == "bar"
assert "password" not in auth
......@@ -28,8 +28,8 @@ def test_get_http_auth(config, with_simple_keyring, dummy_keyring):
assert manager.keyring.is_available()
auth = manager.get_http_auth("foo")
assert "bar" == auth["username"]
assert "baz" == auth["password"]
assert auth["username"] == "bar"
assert auth["password"] == "baz"
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):
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):
......@@ -60,7 +60,7 @@ def test_get_pypi_token(config, with_simple_keyring, dummy_keyring):
manager = PasswordManager(config)
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):
......@@ -80,8 +80,8 @@ def test_set_http_password_with_unavailable_backend(config, with_fail_keyring):
manager.set_http_password("foo", "bar", "baz")
auth = config.get("http-basic.foo")
assert "bar" == auth["username"]
assert "baz" == auth["password"]
assert auth["username"] == "bar"
assert auth["password"] == "baz"
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()
auth = manager.get_http_auth("foo")
assert "bar" == auth["username"]
assert "baz" == auth["password"]
assert auth["username"] == "bar"
assert auth["password"] == "baz"
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):
assert not manager.keyring.is_available()
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):
......@@ -123,7 +123,7 @@ def test_get_pypi_token_with_unavailable_backend(config, with_fail_keyring):
manager = PasswordManager(config)
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):
......@@ -166,5 +166,5 @@ def test_get_http_auth_from_environment_variables(environ, config, with_simple_k
auth = manager.get_http_auth("foo")
assert "bar" == auth["username"]
assert "baz" == auth["password"]
assert auth["username"] == "bar"
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