Skip to content

Commit

Permalink
tests: fix broken mock on CPython 3.12.8+ (#903)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Dec 13, 2024
1 parent ea95a1e commit 28bbaa5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nox/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

__all__ = ["CommandFailed", "ExternalType", "run", "which"]

_PLATFORM = sys.platform


def __dir__() -> list[str]:
return __all__
Expand Down Expand Up @@ -72,7 +74,7 @@ def _clean_env(env: Mapping[str, str | None] | None = None) -> dict[str, str] |
clean_env = {k: v for k, v in env.items() if v is not None}

# Ensure systemroot is passed down, otherwise Windows will explode.
if sys.platform == "win32":
if _PLATFORM.startswith("win"):
clean_env.setdefault("SYSTEMROOT", os.environ.get("SYSTEMROOT", ""))

return clean_env
Expand Down
2 changes: 1 addition & 1 deletion tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_run_env_remove(monkeypatch: pytest.MonkeyPatch) -> None:
)


@mock.patch("sys.platform", "win32")
@mock.patch("nox.command._PLATFORM", "win32")
def test_run_env_systemroot() -> None:
systemroot = os.environ.setdefault("SYSTEMROOT", "sigil")

Expand Down

0 comments on commit 28bbaa5

Please sign in to comment.