Skip to content

Commit

Permalink
Fix for Windows cache directory
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb authored and romain-intel committed Sep 3, 2024
1 parent 2417dfc commit 01d5d45
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/test_pip_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ def test_it_uses_pip_repositories_with_env_var_substitution(
monkeypatch.chdir(directory)
environment_file = directory / "environment.yaml"
assert environment_file.exists(), list(directory.iterdir())
assert DEFAULT_CACHE_DIR.name == "pypoetry-conda-lock"
shutil.rmtree(DEFAULT_CACHE_DIR, ignore_errors=True)
clear_poetry_cache()

# WHEN I create the lockfile
run_lock([directory / "environment.yaml"], conda_exe=conda_exe)
Expand Down Expand Up @@ -176,3 +175,16 @@ def test_it_uses_pip_repositories_with_env_var_substitution(
"Password environment variable was not respected, See full lock-file:\n"
+ lockfile_content
)


def clear_poetry_cache() -> None:
# We are going to rmtree the cache directory. Let's be extra careful to make
# sure we only delete a directory named "pypoetry-conda-lock" or one of its
# subdirectories.
to_delete = DEFAULT_CACHE_DIR.resolve()
assert to_delete.name == "pypoetry-conda-lock" or (
to_delete.parent.name == "pypoetry-conda-lock" and to_delete.name == "Cache"
)
# Do another independent check that triggers even if we're in optimized mode
if "pypoetry-conda-lock" in to_delete.parts:
shutil.rmtree(DEFAULT_CACHE_DIR, ignore_errors=True)

0 comments on commit 01d5d45

Please sign in to comment.