From 394e7161fd8f4951854774cd1a08e22e2f3a614d Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 10 Feb 2024 18:19:29 +0100 Subject: [PATCH] Save mock private pypi package to temp directory Closes #591 --- tests/test_pip_repositories.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/tests/test_pip_repositories.py b/tests/test_pip_repositories.py index 43392154..695e8d6e 100644 --- a/tests/test_pip_repositories.py +++ b/tests/test_pip_repositories.py @@ -35,23 +35,17 @@ """ -_PRIVATE_PACKAGE_SDIST_PATH = ( - Path(__file__).parent / "test-pip-repositories" / "fake-private-package-1.0.0" -) - -@pytest.fixture(scope="module") -def private_package_tar(): - tar_path = _PRIVATE_PACKAGE_SDIST_PATH.parent / "fake-private-package-1.0.0.tar.gz" +@pytest.fixture +def private_package_tar(tmp_path: Path): + sdist_path = ( + clone_test_dir("test-pip-repositories", tmp_path) / "fake-private-package-1.0.0" + ) + assert sdist_path.exists() + tar_path = sdist_path / "fake-private-package-1.0.0.tar.gz" with tarfile.open(tar_path, "w:gz") as tar: - tar.add( - _PRIVATE_PACKAGE_SDIST_PATH, - arcname=os.path.basename(_PRIVATE_PACKAGE_SDIST_PATH), - ) - try: - yield tar_path - finally: - os.remove(tar_path) + tar.add(sdist_path, arcname=os.path.basename(sdist_path)) + return tar_path @pytest.fixture(