Skip to content

Commit

Permalink
Generate mock private pypi package into temp directory
Browse files Browse the repository at this point in the history
Closes conda#591
  • Loading branch information
maresb committed Feb 10, 2024
1 parent 09e58c9 commit 6a10862
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions tests/test_pip_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,17 @@
</html>
"""

_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):
package_path = (
clone_test_dir("test-pip-repositories", tmp_path) / "fake-private-package-1.0.0"
)
assert package_path.exists()
tar_path = package_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(package_path, arcname=os.path.basename(package_path))
return tar_path


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit 6a10862

Please sign in to comment.