Skip to content

Commit

Permalink
move directory metadata test out of req install tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Aug 2, 2023
1 parent a2ad46f commit 913c02f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
14 changes: 14 additions & 0 deletions tests/unit/metadata/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@ def test_dist_found_in_zip(tmp_path: Path) -> None:
dist = get_environment([location]).get_distribution("pkg")
assert dist is not None and dist.location is not None
assert Path(dist.location) == Path(location)


@pytest.mark.parametrize(
"path",
(
"/path/to/foo.egg-info".replace("/", os.path.sep),
# Tests issue fixed by https://github.com/pypa/pip/pull/2530
"/path/to/foo.egg-info/".replace("/", os.path.sep),
),
)
def test_trailing_slash_directory_metadata(path: str) -> None:
dist = get_directory_distribution(path)
assert dist.raw_name == dist.canonical_name == "foo"
assert dist.location == "/path/to".replace("/", os.path.sep)
17 changes: 0 additions & 17 deletions tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
PreviousBuildDirError,
)
from pip._internal.index.package_finder import PackageFinder
from pip._internal.metadata import select_backend
from pip._internal.models.direct_url import ArchiveInfo, DirectUrl, DirInfo, VcsInfo
from pip._internal.models.link import Link
from pip._internal.network.session import PipSession
Expand Down Expand Up @@ -600,22 +599,6 @@ def test_url_preserved_editable_req(self) -> None:
assert req.link is not None
assert req.link.url == url

@pytest.mark.parametrize(
"path",
(
"/path/to/foo.egg-info".replace("/", os.path.sep),
# Tests issue fixed by https://github.com/pypa/pip/pull/2530
"/path/to/foo.egg-info/".replace("/", os.path.sep),
),
)
def test_get_dist(self, path: str) -> None:
req = install_req_from_line("foo")
req.metadata_directory = path
dist = req.get_dist()
assert isinstance(dist, select_backend().Distribution)
assert dist.raw_name == dist.canonical_name == "foo"
assert dist.location == "/path/to".replace("/", os.path.sep)

def test_markers(self) -> None:
for line in (
# recommended syntax
Expand Down

0 comments on commit 913c02f

Please sign in to comment.