Skip to content

Commit 72f92fb

Browse files
committed
fix: remove clear=True from test_env to preserve PATH on Windows
The test_env fixture was using mocker.patch.dict(os.environ, ..., clear=True) which cleared ALL environment variables including PATH. This broke git operations on Windows where git.exe cannot be found without PATH. Since tests are already protected by comprehensive mocking (Coder.create, InputOutput, --exit flags), clearing the environment is unnecessary security theater. The real protection is the mocking layer, not environment isolation. Benefits of this change: - Fixes ~55 test failures on Windows (git command not found) - Allows debugging with environment variables (AIDER_VERBOSE=1, etc.) - Simpler fixture without platform-specific whitelisting - Relies on existing mock boundaries for API call prevention All 104 tests passing on macOS.
1 parent 738302a commit 72f92fb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tests/basic/test_main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ def test_env(mocker, temp_cwd, temp_home):
6363
6464
All resources are automatically cleaned up by dependency fixtures and mocker.
6565
"""
66-
clean_env = {
66+
test_env_vars = {
6767
"OPENAI_API_KEY": "deadbeef",
6868
"AIDER_CHECK_UPDATE": "false",
6969
"AIDER_ANALYTICS": "false",
7070
}
7171

7272
if platform.system() == "Windows":
73-
clean_env["USERPROFILE"] = temp_home
73+
test_env_vars["USERPROFILE"] = temp_home
7474
else:
75-
clean_env["HOME"] = temp_home
75+
test_env_vars["HOME"] = temp_home
7676

77-
mocker.patch.dict(os.environ, clean_env, clear=True)
77+
mocker.patch.dict(os.environ, test_env_vars)
7878
mocker.patch("builtins.input", return_value=None)
7979
mocker.patch("aider.io.webbrowser.open")
8080

0 commit comments

Comments
 (0)