Skip to content

Commit 8e4fef6

Browse files
committed
test: use errno.ENOENT for command not found assertion
- Replace error message text matching with errno.ENOENT check - Improves test reliability across different system languages - Removes dependency on specific error message strings"
1 parent de89457 commit 8e4fef6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tests/client/test_stdio.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import errno
12
import os
23
import shutil
34
import sys
@@ -94,13 +95,8 @@ async def test_stdio_client_nonexistent_command():
9495
async with stdio_client(server_params) as (_, _):
9596
pass
9697

97-
# The error should indicate the command was not found
98-
error_message = str(exc_info.value)
99-
assert (
100-
"nonexistent" in error_message
101-
or "not found" in error_message.lower()
102-
or "cannot find the file" in error_message.lower() # Windows error message
103-
)
98+
# The error should indicate the command was not found (ENOENT: No such file or directory)
99+
assert exc_info.value.errno == errno.ENOENT
104100

105101

106102
@pytest.mark.anyio

0 commit comments

Comments
 (0)