11import os
2- import pytest
32import tempfile
43
4+ import pytest
5+
56from mcp_shell_server .shell_executor import ShellExecutor
67
78
@@ -99,7 +100,7 @@ async def test_execute_in_directory(executor, temp_test_dir, monkeypatch):
99100async def test_execute_with_file_in_directory (executor , temp_test_dir , monkeypatch ):
100101 """Test command execution with a file in the specified directory"""
101102 monkeypatch .setenv ("ALLOW_COMMANDS" , "ls,cat" )
102-
103+
103104 # Create a test file in the temporary directory
104105 test_file = os .path .join (temp_test_dir , "test.txt" )
105106 with open (test_file , "w" ) as f :
@@ -108,7 +109,7 @@ async def test_execute_with_file_in_directory(executor, temp_test_dir, monkeypat
108109 # Test ls command
109110 result = await executor .execute (["ls" ], directory = temp_test_dir )
110111 assert "test.txt" in result ["stdout" ]
111-
112+
112113 # Test cat command
113114 result = await executor .execute (["cat" , "test.txt" ], directory = temp_test_dir )
114115 assert result ["stdout" ].strip () == "test content"
@@ -127,7 +128,7 @@ async def test_execute_with_nonexistent_directory(executor, monkeypatch):
127128async def test_execute_with_file_as_directory (executor , temp_test_dir , monkeypatch ):
128129 """Test command execution with a file specified as directory"""
129130 monkeypatch .setenv ("ALLOW_COMMANDS" , "ls" )
130-
131+
131132 # Create a test file
132133 test_file = os .path .join (temp_test_dir , "test.txt" )
133134 with open (test_file , "w" ) as f :
@@ -152,13 +153,13 @@ async def test_execute_with_no_directory_specified(executor, monkeypatch):
152153async def test_execute_with_nested_directory (executor , temp_test_dir , monkeypatch ):
153154 """Test command execution in a nested directory"""
154155 monkeypatch .setenv ("ALLOW_COMMANDS" , "pwd,mkdir,ls" )
155-
156+
156157 # Create a nested directory
157158 nested_dir = os .path .join (temp_test_dir , "nested" )
158159 os .mkdir (nested_dir )
159160 nested_real_path = os .path .realpath (nested_dir )
160-
161+
161162 result = await executor .execute (["pwd" ], directory = nested_dir )
162163 assert result ["error" ] is None
163164 assert result ["status" ] == 0
164- assert result ["stdout" ].strip () == nested_real_path
165+ assert result ["stdout" ].strip () == nested_real_path
0 commit comments