Skip to content

Commit

Permalink
use pytest's tmp_path
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
Micah Denbraver committed May 8, 2024
1 parent 7a8972e commit 3a9302e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 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:
infile.write(f"-e {test_package_path}")
infile.close()
with open(requirements_in_path, 'w') as requirements_in_file:
requirements_in_file.write(f"-e {test_package_path}")

[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 3a9302e

Please sign in to comment.