circuitpython/tests/basics/dict_fixed.py

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

49 lines
849 B
Python
Raw Normal View History

# test that fixed dictionaries cannot be modified
try:
2023-08-22 11:15:46 -04:00
import errno
except ImportError:
print("SKIP")
raise SystemExit
2023-08-22 11:15:46 -04:00
# Save a copy of errno.errorcode, so we can check later
# that it hasn't been modified.
2023-08-22 11:15:46 -04:00
errorcode_copy = errno.errorcode.copy()
try:
2023-08-22 11:15:46 -04:00
errno.errorcode.popitem()
except TypeError:
print("TypeError")
try:
2023-08-22 11:15:46 -04:00
errno.errorcode.pop(0)
except TypeError:
print("TypeError")
try:
2023-08-22 11:15:46 -04:00
errno.errorcode.setdefault(0, 0)
except TypeError:
print("TypeError")
try:
2023-08-22 11:15:46 -04:00
errno.errorcode.update([(1, 2)])
except TypeError:
print("TypeError")
try:
2023-08-22 11:15:46 -04:00
del errno.errorcode[1]
except TypeError:
print("TypeError")
try:
2023-08-22 11:15:46 -04:00
errno.errorcode[1] = 'foo'
except TypeError:
print("TypeError")
try:
2023-08-22 11:15:46 -04:00
errno.errorcode.clear()
except TypeError:
print("TypeError")
2023-08-22 11:15:46 -04:00
assert errno.errorcode == errorcode_copy