Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
188aa1e
1
Parent(s): bf00022
Remove asyncio.run
Browse files- tests/cli/test_cli.py +4 -9
tests/cli/test_cli.py
CHANGED
|
@@ -312,7 +312,7 @@ class TestInspectCommand:
|
|
| 312 |
@patch("fastmcp.cli.cli.run_module.parse_file_path")
|
| 313 |
@patch("fastmcp.cli.cli.run_module.import_server")
|
| 314 |
@patch("fastmcp.cli.cli.inspect_fastmcp")
|
| 315 |
-
def test_inspect_command_basic(
|
| 316 |
self, mock_inspect, mock_import_server, mock_parse_file_path, tmp_path
|
| 317 |
):
|
| 318 |
"""Test basic inspect command functionality."""
|
|
@@ -345,24 +345,19 @@ class TestInspectCommand:
|
|
| 345 |
]
|
| 346 |
)
|
| 347 |
|
| 348 |
-
|
| 349 |
-
import asyncio
|
| 350 |
-
|
| 351 |
-
asyncio.run(command(**bound.arguments))
|
| 352 |
|
| 353 |
# Verify the output file was created
|
| 354 |
assert output_file.exists()
|
| 355 |
assert output_file.read_text() == '{"name": "TestServer"}'
|
| 356 |
|
| 357 |
@patch("fastmcp.cli.cli.run_module.import_server")
|
| 358 |
-
def test_inspect_command_failure(self, mock_import_server):
|
| 359 |
"""Test inspect command handling failures."""
|
| 360 |
mock_import_server.side_effect = Exception("Import failed")
|
| 361 |
|
| 362 |
with pytest.raises(SystemExit) as exc_info:
|
| 363 |
command, bound, _ = app.parse_args(["inspect", "server.py"])
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
asyncio.run(command(**bound.arguments))
|
| 367 |
|
| 368 |
assert exc_info.value.code == 1
|
|
|
|
| 312 |
@patch("fastmcp.cli.cli.run_module.parse_file_path")
|
| 313 |
@patch("fastmcp.cli.cli.run_module.import_server")
|
| 314 |
@patch("fastmcp.cli.cli.inspect_fastmcp")
|
| 315 |
+
async def test_inspect_command_basic(
|
| 316 |
self, mock_inspect, mock_import_server, mock_parse_file_path, tmp_path
|
| 317 |
):
|
| 318 |
"""Test basic inspect command functionality."""
|
|
|
|
| 345 |
]
|
| 346 |
)
|
| 347 |
|
| 348 |
+
await command(**bound.arguments)
|
|
|
|
|
|
|
|
|
|
| 349 |
|
| 350 |
# Verify the output file was created
|
| 351 |
assert output_file.exists()
|
| 352 |
assert output_file.read_text() == '{"name": "TestServer"}'
|
| 353 |
|
| 354 |
@patch("fastmcp.cli.cli.run_module.import_server")
|
| 355 |
+
async def test_inspect_command_failure(self, mock_import_server):
|
| 356 |
"""Test inspect command handling failures."""
|
| 357 |
mock_import_server.side_effect = Exception("Import failed")
|
| 358 |
|
| 359 |
with pytest.raises(SystemExit) as exc_info:
|
| 360 |
command, bound, _ = app.parse_args(["inspect", "server.py"])
|
| 361 |
+
await command(**bound.arguments)
|
|
|
|
|
|
|
| 362 |
|
| 363 |
assert exc_info.value.code == 1
|