Skip to content

Commit

Permalink
Also consider '-' separator in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Feb 26, 2025
1 parent 8280e2c commit 22355fc
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pkg_resources/tests/test_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,21 +462,24 @@ def fake_site_packages(self, tmp_path, monkeypatch, dist_files):
}

@pytest.mark.parametrize(
("name", "version", "req"),
("version", "requirement"),
[
("pkg1.mod", "1.2.3", "pkg1.mod>=1"),
("pkg2.mod", "0.42", "pkg2.mod>=0.4"),
("pkg3.mod", "1.2.3.4", "pkg3.mod<=2"),
("pkg4.mod", "0.42.1", "pkg4.mod>0.2,<1"),
("1.2.3", "pkg1.mod>=1"),
("0.42", "pkg2.mod>=0.4"),
("1.2.3.4", "pkg3.mod<=2"),
("0.42.1", "pkg4.mod>0.2,<1"),
],
)
def test_require_normalised_name(self, tmp_path, monkeypatch, name, version, req):
def test_require_non_normalised_name(
self, tmp_path, monkeypatch, version, requirement
):
# https://github.com/pypa/setuptools/issues/4853
site_packages = self.fake_site_packages(tmp_path, monkeypatch, self.FILES)
ws = pkg_resources.WorkingSet([site_packages])

[dist] = ws.require(req)
assert dist.version == version
assert os.path.samefile(
os.path.commonpath([dist.location, site_packages]), site_packages
)
for req in [requirement, requirement.replace(".", "-")]:
[dist] = ws.require(req)
assert dist.version == version
assert os.path.samefile(
os.path.commonpath([dist.location, site_packages]), site_packages
)

0 comments on commit 22355fc

Please sign in to comment.