Skip to content

Commit

Permalink
use pytest's tmp_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah Denbraver committed May 8, 2024
1 parent 7a8972e commit c3882a1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/test_pip_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@
from .constants import PACKAGES_RELATIVE_PATH


def test_parse_requirements_preserve_editable_relative_path(repository):
def test_parse_requirements_preserve_editable_relative_path(tmp_path, repository):
test_package_path = str(
PurePosixPath(Path(PACKAGES_RELATIVE_PATH)) / "small_fake_a"
)
requirements_in_path = str(tmp_path / "requirements.in")

infile = tempfile.NamedTemporaryFile("w", delete=False)
try:
with open(requirements_in_path, 'w') as infile:
infile.write(f"-e {test_package_path}")
infile.close()

[install_requirement] = parse_requirements(
infile.name, session=repository.session
)
finally:
os.unlink(infile.name)
[install_requirement] = parse_requirements(
requirements_in_path, session=repository.session
)

assert install_requirement.link.url == test_package_path
assert install_requirement.link.file_path == test_package_path

0 comments on commit c3882a1

Please sign in to comment.