Skip to content

Commit

Permalink
Merge pull request #3 from hsaunders1904/fix_cache_dir_bug_on_windows
Browse files Browse the repository at this point in the history
Fix cache dir bug on windows
  • Loading branch information
hsaunders1904 authored Apr 5, 2023
2 parents 50e7294 + a5813d9 commit 0435f8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyautoenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def windows_poetry_cache_dir() -> Union[Path, None]:
"""Return the poetry cache directory for Windows."""
if not (app_data := os.environ.get("LOCALAPPDATA", None)):
return None
return Path(app_data) / "pypoetry"
return Path(app_data) / "pypoetry" / "Cache"


def poetry_env_name(directory: Path) -> Union[str, None]:
Expand Down
12 changes: 9 additions & 3 deletions test_pyautoenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class PoetryTester:
POETRY_DIR: Path
VENV_DIR: Path
NOT_POETRY_DIR = "not_a_poetry_project"
POETRY_PROJ = Path("/python_project")
POETRY_PROJ = Path("python_project")

def setup_method(self):
self.os_patch = mock.patch(OPERATING_SYSTEM, return_value=self.OS)
Expand Down Expand Up @@ -371,7 +371,7 @@ def test_nothing_happens_given_name_cannot_be_parsed_from_pyproject(
self,
pyproject_toml,
):
assert (self.POETRY_PROJ / "pyproject.toml").write_text(pyproject_toml)
assert Path("python_project/pyproject.toml").write_text(pyproject_toml)
stdout = StringIO()

assert pyautoenv.main([str(self.POETRY_PROJ)], stdout) == 0
Expand All @@ -382,7 +382,13 @@ class TestPoetryWindows(PoetryTester):
ACTIVATOR = Path("Scripts") / "Activate.ps1"
OS = pyautoenv.Os.WINDOWS
POETRY_DIR = (
Path("C") / "Users" / "user" / "AppData" / "Local" / "pypoetry"
Path("C")
/ "Users"
/ "user"
/ "AppData"
/ "Local"
/ "pypoetry"
/ "Cache"
)
VENV_DIR = POETRY_DIR / "virtualenvs" / "python_project-frtSrewI-py3.11"

Expand Down

0 comments on commit 0435f8a

Please sign in to comment.