forked from python-poetry/poetry-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dependency): do not discard unknown urls
Prior to this change, when parsing PEP 508 requirement strings, the `Dependency` class silently discarded any URI tokens that cannot be validated as existing files. Resolves: python-poetry/poetry#10068
- Loading branch information
Showing
2 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
from poetry.core.constraints.version.exceptions import ParseConstraintError | ||
from poetry.core.packages.dependency import Dependency | ||
from poetry.core.packages.directory_dependency import DirectoryDependency | ||
from poetry.core.packages.file_dependency import FileDependency | ||
from poetry.core.version.markers import InvalidMarkerError | ||
from poetry.core.version.markers import parse_marker | ||
from poetry.core.version.requirements import InvalidRequirementError | ||
|
@@ -218,6 +220,27 @@ def test_to_pep_508_with_invalid_requirement(requirement: str) -> None: | |
_ = Dependency.create_from_pep_508(requirement) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("requirement", "dependency_type"), | ||
[ | ||
( | ||
"eflips-depot @ [email protected]:mpm-tu-berlin/eflips-depot.git@feature/allow-only-oppo-charging", | ||
DirectoryDependency, | ||
), | ||
( | ||
"eflips-depot @ [email protected]:mpm-tu-berlin/eflips-depot.git@feature/allow-only-oppo-charging.whl", | ||
FileDependency, | ||
), | ||
], | ||
) | ||
def test_to_pep_508_with_invalid_path_requirement( | ||
requirement: str, dependency_type: type[FileDependency | DirectoryDependency] | ||
) -> None: | ||
dependency = Dependency.create_from_pep_508(requirement) | ||
assert isinstance(dependency, dependency_type) | ||
assert dependency.source_url | ||
|
||
|
||
def test_complete_name() -> None: | ||
assert Dependency("foo", ">=1.2.3").complete_name == "foo" | ||
assert ( | ||
|