Skip to content

Commit 0946c55

Browse files
committed
Fix a test which improperly formulated file URIs
String-formatting in a test prepended `file://` to a path, which does not produce a valid file URI on Windows.
1 parent c0f0572 commit 0946c55

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

tests/test_repository_pypi.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def mock_get(*args, **kwargs):
429429
assert actual_data is None
430430

431431

432-
def test_name_collision(from_line, pypi_repository, make_package, make_sdist, tmpdir):
432+
def test_name_collision(from_line, pypi_repository, make_package, make_sdist, tmp_path):
433433
"""
434434
Test to ensure we don't fail if there are multiple URL-based requirements
435435
ending with the same filename where later ones depend on earlier, e.g.
@@ -446,7 +446,7 @@ def test_name_collision(from_line, pypi_repository, make_package, make_sdist, tm
446446
}
447447

448448
for pkg_name, pkg in packages.items():
449-
pkg_path = tmpdir / pkg_name
449+
pkg_path = tmp_path / pkg_name
450450

451451
make_sdist(pkg, pkg_path, "--formats=zip")
452452

@@ -455,17 +455,13 @@ def test_name_collision(from_line, pypi_repository, make_package, make_sdist, tm
455455
os.path.join(pkg_path, "main.zip"),
456456
)
457457

458-
name_collision_1 = "file://{dist_path}#egg=test_package_1".format(
459-
dist_path=tmpdir / "test_package_1" / "main.zip"
460-
)
461-
ireq = from_line(name_collision_1)
458+
dist_uri_1 = (tmp_path / "test_package_1" / "main.zip").as_uri()
459+
ireq = from_line(f"{dist_uri_1}#egg=test_package_1")
462460
deps = pypi_repository.get_dependencies(ireq)
463461
assert len(deps) == 0
464462

465-
name_collision_2 = "file://{dist_path}#egg=test_package_2".format(
466-
dist_path=tmpdir / "test_package_2" / "main.zip"
467-
)
468-
ireq = from_line(name_collision_2)
463+
dist_uri_2 = (tmp_path / "test_package_2" / "main.zip").as_uri()
464+
ireq = from_line(f"{dist_uri_2}#egg=test_package_2")
469465
deps = pypi_repository.get_dependencies(ireq)
470466
assert len(deps) == 1
471467
assert deps.pop().name == "test-package-1"

0 commit comments

Comments
 (0)