Skip to content

Commit

Permalink
Add failing test for package with invalid specifier in dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul authored and pradyunsg committed May 4, 2024
1 parent b63e279 commit 587854a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<a href="../../../packages/invalid_version-2010i-py3-none-any.whl">invalid_version-2010i-py3-none-any.whl</a>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<body>
<a href="../../../packages/require_invalid_version-0.1-py3-none-any.whl">require_invalid_version-0.1-py3-none-any.whl</a>
<a href="../../../packages/require_invalid_version-1.0-py3-none-any.whl">require_invalid_version-1.0-py3-none-any.whl</a>
</body>
</html>
8 changes: 8 additions & 0 deletions tests/data/packages/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,11 @@ The invalid-version package with a legacy version.
invalid_version-1.0-py3-none-any.whl
------------------------------------
A valid variant of the invalid-version package.

require_invalid_version-0.1-py3-none-any.whl
--------------------------------------------
A valid variant of the require-invalid-version package.

require_invalid_version-1.0-py3-none-any.whl
--------------------------------------------
This package has an invalid version specifier in its requirements.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/functional/test_invalid_versions_and_specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ def test_install_from_index_with_invalid_version(
"install", "--dry-run", "--index-url", index_url, "invalid-version"
)
assert "Would install invalid-version-1.0" in result.stdout


def test_install_from_index_with_invalid_specifier(
script: PipTestEnvironment, data: TestData
) -> None:
"""
Test that pip does not crash when installing a package with an invalid
version specifier in its dependencies.
"""
index_url = data.index_url("require-invalid-version")
result = script.pip(
"install", "--dry-run", "--index-url", index_url, "require-invalid-version"
)
assert "Would install require-invalid-version-0.1" in result.stdout

0 comments on commit 587854a

Please sign in to comment.