2015-03-25 23:10:09 +00:00
|
|
|
# test errors from bad operations (unary, binary, etc)
|
|
|
|
|
|
|
|
# unsupported unary operators
|
2018-02-14 05:50:20 +00:00
|
|
|
try:
|
|
|
|
~None
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
~''
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
~[]
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 23:10:09 +00:00
|
|
|
|
|
|
|
# unsupported binary operators
|
2018-02-14 05:50:20 +00:00
|
|
|
try:
|
|
|
|
False in True
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
1 * {}
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
1 in 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 23:10:09 +00:00
|
|
|
|
|
|
|
# unsupported subscription
|
2018-02-14 05:50:20 +00:00
|
|
|
try:
|
|
|
|
1[0] = 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
'a'[0] = 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
del 1[0]
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 23:10:09 +00:00
|
|
|
|
|
|
|
# not an iterator
|
2018-02-14 05:50:20 +00:00
|
|
|
try:
|
|
|
|
next(1)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 23:10:09 +00:00
|
|
|
|
|
|
|
# must be an exception type
|
2018-02-14 05:50:20 +00:00
|
|
|
try:
|
|
|
|
raise 1
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-03-25 23:10:09 +00:00
|
|
|
|
|
|
|
# no such name in import
|
2018-02-14 05:50:20 +00:00
|
|
|
try:
|
|
|
|
from sys import youcannotimportmebecauseidontexist
|
|
|
|
except ImportError:
|
|
|
|
print('ImportError')
|