tests: Automatically skip tests that require eval, exec or frozenset.

This commit is contained in:
Damien George 2018-02-14 16:46:44 +11:00
parent 24c513cbc3
commit 6031957473
8 changed files with 47 additions and 1 deletions

View File

@ -1,5 +1,11 @@
# builtin eval
try:
eval
except NameError:
print("SKIP")
raise SystemExit
eval('1 + 2')
eval('1 + 2\n')
eval('1 + 2\n\n#comment\n')

View File

@ -1,5 +1,11 @@
# test if eval raises SyntaxError
try:
eval
except NameError:
print("SKIP")
raise SystemExit
try:
print(eval("[1,,]"))
except SyntaxError:

View File

@ -1,3 +1,11 @@
# test builtin exec
try:
exec
except NameError:
print("SKIP")
raise SystemExit
print(exec("def foo(): return 42"))
print(foo())

View File

@ -1,5 +1,11 @@
# test passing a string object as the key for a keyword argument
try:
exec
except NameError:
print("SKIP")
raise SystemExit
# they key in this dict is a string object and is not interned
args = {'thisisaverylongargumentname': 123}

View File

@ -1,5 +1,12 @@
# test the lexer
try:
eval
exec
except NameError:
print("SKIP")
raise SystemExit
# __debug__ is a special symbol
print(type(__debug__))

View File

@ -1,5 +1,11 @@
# tests that differ when running under Python 3.4 vs 3.5/3.6
try:
exec
except NameError:
print("SKIP")
raise SystemExit
# from basics/fun_kwvarargs.py
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
def f4(*vargs, **kwargs):

View File

@ -1,5 +1,11 @@
# test syntax errors
try:
exec
except NameError:
print("SKIP")
raise SystemExit
def test_syntax(code):
try:
exec(code)

View File

@ -1,7 +1,8 @@
# test that iterating doesn't use the heap
try:
frozenset
import array
except ImportError:
except (NameError, ImportError):
print("SKIP")
raise SystemExit