Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve install conflict warning #8594

Merged
merged 14 commits into from
Jul 28, 2020
Prev Previous commit
Next Next commit
Change {matches -> contains}_expected_lines
This also updates invocations that can't be translated as-is into a
different equivalent check.
  • Loading branch information
pradyunsg committed Jul 27, 2020
commit e4f8e0a2b87bd3ad90fc883b6133512acbf9a0c8
27 changes: 9 additions & 18 deletions tests/functional/test_install_check.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from tests.lib import create_test_package_with_setup


def matches_expected_lines(string, expected_lines, exact=True):
if exact:
return set(string.splitlines()) == set(expected_lines)
# If not exact, check that all expected lines are present
def contains_expected_lines(string, expected_lines):
return set(expected_lines) <= set(string.splitlines())


Expand Down Expand Up @@ -41,8 +38,7 @@ def test_check_install_canonicalization(script, deprecated_python):
"ERROR: pkga 1.0 requires SPECIAL.missing, which is not installed.",
]
# Deprecated python versions produce an extra warning on stderr
assert matches_expected_lines(
result.stderr, expected_lines, exact=not deprecated_python)
assert contains_expected_lines(result.stderr, expected_lines)
assert result.returncode == 0

# Install the second missing package and expect that there is no warning
Expand All @@ -51,16 +47,15 @@ def test_check_install_canonicalization(script, deprecated_python):
result = script.pip(
'install', '--no-index', special_path, '--quiet',
)
assert matches_expected_lines(
result.stderr, [], exact=not deprecated_python)
assert "requires" not in result.stderr
assert result.returncode == 0

# Double check that all errors are resolved in the end
result = script.pip('check')
expected_lines = [
"No broken requirements found.",
]
assert matches_expected_lines(result.stdout, expected_lines)
assert contains_expected_lines(result.stdout, expected_lines)
assert result.returncode == 0


Expand All @@ -85,33 +80,29 @@ def test_check_install_does_not_warn_for_out_of_graph_issues(

# Install a package without it's dependencies
result = script.pip('install', '--no-index', pkg_broken_path, '--no-deps')
# Deprecated python versions produce an extra warning on stderr
assert matches_expected_lines(
result.stderr, [], exact=not deprecated_python)
assert "requires" not in result.stderr

# Install conflict package
result = script.pip(
'install', '--no-index', pkg_conflict_path, allow_stderr_error=True,
)
assert matches_expected_lines(result.stderr, [
"ERROR: broken 1.0 requires missing, which is not installed.",
assert contains_expected_lines(result.stderr, [
(
"ERROR: broken 1.0 has requirement conflict<1.0, but "
"you'll have conflict 1.0 which is incompatible."
),
], exact=not deprecated_python)
])

# Install unrelated package
result = script.pip(
'install', '--no-index', pkg_unrelated_path, '--quiet',
)
# should not warn about broken's deps when installing unrelated package
assert matches_expected_lines(
result.stderr, [], exact=not deprecated_python)
assert "requires" not in result.stderr

result = script.pip('check', expect_error=True)
expected_lines = [
"broken 1.0 requires missing, which is not installed.",
"broken 1.0 has requirement conflict<1.0, but you have conflict 1.0.",
]
assert matches_expected_lines(result.stdout, expected_lines)
assert contains_expected_lines(result.stdout, expected_lines)