Skip to content

Commit 61ab7ea

Browse files
committed
chore: add missing newlines at the end of files to comply with PEP 8 standards
style: format test files by removing unnecessary blank lines for better readability
1 parent 0109538 commit 61ab7ea

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

mcp_shell_server/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ async def main() -> None:
120120
)
121121
except Exception as e:
122122
logger.error(f"Server error: {str(e)}")
123-
raise
123+
raise

mcp_shell_server/shell_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,4 @@ async def execute(
169169
"stdout": "",
170170
"stderr": str(e),
171171
"execution_time": time.time() - start_time,
172-
}
172+
}

tests/test_server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import tempfile
3+
34
import pytest
45
from mcp.types import TextContent, Tool
56

@@ -104,7 +105,7 @@ async def test_call_tool_with_directory(temp_test_dir, monkeypatch):
104105
async def test_call_tool_with_file_operations(temp_test_dir, monkeypatch):
105106
"""Test file operations in a specific directory"""
106107
monkeypatch.setenv("ALLOW_COMMANDS", "ls,cat")
107-
108+
108109
# Create a test file
109110
test_file = os.path.join(temp_test_dir, "test.txt")
110111
with open(test_file, "w") as f:
@@ -141,7 +142,7 @@ async def test_call_tool_with_nonexistent_directory(monkeypatch):
141142
async def test_call_tool_with_file_as_directory(temp_test_dir, monkeypatch):
142143
"""Test command execution with a file specified as directory"""
143144
monkeypatch.setenv("ALLOW_COMMANDS", "ls")
144-
145+
145146
# Create a test file
146147
test_file = os.path.join(temp_test_dir, "test.txt")
147148
with open(test_file, "w") as f:
@@ -159,14 +160,14 @@ async def test_call_tool_with_file_as_directory(temp_test_dir, monkeypatch):
159160
async def test_call_tool_with_nested_directory(temp_test_dir, monkeypatch):
160161
"""Test command execution in a nested directory"""
161162
monkeypatch.setenv("ALLOW_COMMANDS", "pwd,mkdir")
162-
163+
163164
# Create a nested directory
164165
nested_dir = os.path.join(temp_test_dir, "nested")
165166
os.mkdir(nested_dir)
166167
nested_real_path = os.path.realpath(nested_dir)
167-
168+
168169
result = await call_tool("execute", {
169170
"command": ["pwd"],
170171
"directory": nested_dir
171172
})
172-
assert result[0].text.strip() == nested_real_path
173+
assert result[0].text.strip() == nested_real_path

tests/test_shell_executor.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
2-
import pytest
32
import tempfile
43

4+
import pytest
5+
56
from mcp_shell_server.shell_executor import ShellExecutor
67

78

@@ -99,7 +100,7 @@ async def test_execute_in_directory(executor, temp_test_dir, monkeypatch):
99100
async 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):
127128
async 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):
152153
async 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

Comments
 (0)