circuitpython/tests/basics/errno1.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
593 B
Python
Raw Normal View History

2023-08-22 11:15:46 -04:00
# test errno's and errno module
try:
2023-08-22 11:15:46 -04:00
import errno
except ImportError:
print("SKIP")
raise SystemExit
# check that constants exist and are integers
2023-08-22 11:15:46 -04:00
print(type(errno.EIO))
# check that errors are rendered in a nice way
2023-08-22 11:15:46 -04:00
msg = str(OSError(errno.EIO))
print(msg[:7], msg[-5:])
2023-08-22 11:15:46 -04:00
msg = str(OSError(errno.EIO, "details"))
print(msg[:7], msg[-14:])
2023-08-22 11:15:46 -04:00
msg = str(OSError(errno.EIO, "details", "more details"))
print(msg[:1], msg[-28:])
# check that unknown errno is still rendered
print(str(OSError(9999)))
# this tests a failed constant lookup in errno
2023-08-22 11:15:46 -04:00
errno = errno
print(errno.__name__)