diff --git a/tests/functional/test_install_check.py b/tests/functional/test_install_check.py index 017d6256b..d13e93f5d 100644 --- a/tests/functional/test_install_check.py +++ b/tests/functional/test_install_check.py @@ -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()) @@ -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 @@ -51,8 +47,7 @@ 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 @@ -60,7 +55,7 @@ def test_check_install_canonicalization(script, deprecated_python): 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 @@ -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)