diff --git a/tests/test_pip_compat.py b/tests/test_pip_compat.py index caa36499..0c5674b7 100644 --- a/tests/test_pip_compat.py +++ b/tests/test_pip_compat.py @@ -2,6 +2,7 @@ import os import tempfile +from pathlib import Path, PurePosixPath import pytest @@ -18,14 +19,20 @@ def repository(): def test_parse_requirements_preserve_editable_relative(repository): - test_package_path = os.path.join(PACKAGES_RELATIVE_PATH, "small_fake_a") + test_package_path = str( + PurePosixPath(Path(PACKAGES_RELATIVE_PATH)) / "small_fake_a" + ) - with tempfile.NamedTemporaryFile("w") as infile: + infile = tempfile.NamedTemporaryFile("w", delete=False) + try: infile.write(f"-e {test_package_path}") - infile.flush() + infile.close() + [install_requirement] = parse_requirements( infile.name, session=repository.session ) + finally: + os.unlink(infile.name) assert install_requirement.link.url == test_package_path assert install_requirement.link.file_path == test_package_path