@@ -71,17 +71,25 @@ def test_terminal_ws_wrong_token(client: TestClient) -> None:
7171
7272
7373class TestCreateShellEnvironment :
74- def test_create_shell_environment_default_cwd (self ) -> None :
74+ def test_create_shell_environment_default_cwd (
75+ self , monkeypatch : pytest .MonkeyPatch
76+ ) -> None :
7577 """Test shell environment creation with default working directory."""
78+ monkeypatch .delenv ("SHELL" , raising = False )
79+
7680 shell , env = _create_shell_environment ()
7781
7882 assert shell in ["/bin/bash" , "/bin/zsh" , "/bin/sh" ]
7983 assert env ["TERM" ] == "xterm-256color"
8084 assert "LANG" in env
8185 assert "LC_ALL" in env
8286
83- def test_create_shell_environment_custom_cwd (self ) -> None :
87+ def test_create_shell_environment_custom_cwd (
88+ self , monkeypatch : pytest .MonkeyPatch
89+ ) -> None :
8490 """Test shell environment creation with custom working directory."""
91+ monkeypatch .delenv ("SHELL" , raising = False )
92+
8593 with tempfile .TemporaryDirectory () as temp_dir :
8694 shell , env = _create_shell_environment (cwd = temp_dir )
8795
@@ -91,9 +99,14 @@ def test_create_shell_environment_custom_cwd(self) -> None:
9199 @patch ("os.getcwd" )
92100 @patch ("pathlib.Path.home" )
93101 def test_create_shell_environment_fallback_cwd (
94- self , mock_home : Mock , mock_getcwd : Mock
102+ self ,
103+ mock_home : Mock ,
104+ mock_getcwd : Mock ,
105+ monkeypatch : pytest .MonkeyPatch ,
95106 ) -> None :
96107 """Test shell environment creation when getcwd fails."""
108+ monkeypatch .delenv ("SHELL" , raising = False )
109+
97110 mock_getcwd .side_effect = OSError ("No such directory" )
98111 mock_home .return_value = Path ("/home/user" )
99112
@@ -105,9 +118,14 @@ def test_create_shell_environment_fallback_cwd(
105118 @patch ("os.getcwd" )
106119 @patch ("pathlib.Path.home" )
107120 def test_create_shell_environment_ultimate_fallback (
108- self , mock_home : Mock , mock_getcwd : Mock
121+ self ,
122+ mock_home : Mock ,
123+ mock_getcwd : Mock ,
124+ monkeypatch : pytest .MonkeyPatch ,
109125 ) -> None :
110126 """Test shell environment creation when both getcwd and home fail."""
127+ monkeypatch .delenv ("SHELL" , raising = False )
128+
111129 mock_getcwd .side_effect = OSError ("No such directory" )
112130 mock_home .side_effect = Exception ("No home directory" )
113131
0 commit comments