circuitpython/tests/basics/op_error.py
Damien George 025e4b6fbc tests/basics: Split out literal tests that raise SyntaxWarning on CPy.
Fixes issue #7330.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-30 13:41:37 +10:00

62 lines
962 B
Python

# test errors from bad operations (unary, binary, etc)
# unsupported unary operators
try:
~None
except TypeError:
print('TypeError')
try:
~''
except TypeError:
print('TypeError')
try:
~[]
except TypeError:
print('TypeError')
# unsupported binary operators
try:
False in True
except TypeError:
print('TypeError')
try:
1 * {}
except TypeError:
print('TypeError')
try:
1 in 1
except TypeError:
print('TypeError')
# unsupported subscription
try:
1[0] = 1
except TypeError:
print('TypeError')
try:
'a'[0] = 1
except TypeError:
print('TypeError')
try:
del 1[0]
except TypeError:
print('TypeError')
# not an iterator
try:
next(1)
except TypeError:
print('TypeError')
# must be an exception type
try:
raise 1
except TypeError:
print('TypeError')
# no such name in import
try:
from sys import youcannotimportmebecauseidontexist
except ImportError:
print('ImportError')