test: use errno.ENOENT for command not found assertion (#1498)
This commit is contained in:
parent
bbc8b4904e
commit
b7e4ae7542
1 changed files with 4 additions and 8 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -90,17 +91,12 @@ async def test_stdio_client_nonexistent_command():
|
||||||
)
|
)
|
||||||
|
|
||||||
# Should raise an error when trying to start the process
|
# Should raise an error when trying to start the process
|
||||||
with pytest.raises(Exception) as exc_info:
|
with pytest.raises(OSError) as exc_info:
|
||||||
async with stdio_client(server_params) as (_, _):
|
async with stdio_client(server_params) as (_, _):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# The error should indicate the command was not found
|
# The error should indicate the command was not found (ENOENT: No such file or directory)
|
||||||
error_message = str(exc_info.value)
|
assert exc_info.value.errno == errno.ENOENT
|
||||||
assert (
|
|
||||||
"nonexistent" in error_message
|
|
||||||
or "not found" in error_message.lower()
|
|
||||||
or "cannot find the file" in error_message.lower() # Windows error message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue