test: use errno.ENOENT for command not found assertion (#1498)

This commit is contained in:
mingo007 2025-10-24 07:30:50 +08:00 • committed by GitHub
commit b7e4ae7542
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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