tests: Allow tests to pass against CPython 3.5.
All breaking changes going from 3.4 to 3.5 are contained in basics/python34.py.
This commit is contained in:
parent
9e0a3d46b6
commit
34f26ea862
@ -1,6 +1,6 @@
|
||||
# test if eval raises SyntaxError
|
||||
|
||||
try:
|
||||
print(eval("[1, *a]"))
|
||||
print(eval("[1,,]"))
|
||||
except SyntaxError:
|
||||
print("SyntaxError")
|
||||
|
@ -23,9 +23,3 @@ def f4(*vargs, **kwargs):
|
||||
f4(*(1, 2))
|
||||
f4(kw_arg=3)
|
||||
f4(*(1, 2), kw_arg=3)
|
||||
|
||||
# test evaluation order of arguments (in CPy 3.4 it's actually backwards)
|
||||
def print_ret(x):
|
||||
print(x)
|
||||
return x
|
||||
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
|
||||
|
26
tests/basics/python34.py
Normal file
26
tests/basics/python34.py
Normal file
@ -0,0 +1,26 @@
|
||||
# tests that differ when running under Python 3.4 vs 3.5
|
||||
|
||||
# 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):
|
||||
print(vargs, kwargs)
|
||||
def print_ret(x):
|
||||
print(x)
|
||||
return x
|
||||
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
|
||||
|
||||
# from basics/syntaxerror.py
|
||||
# can't have multiple * or ** (in 3.5 we can)
|
||||
def test_syntax(code):
|
||||
try:
|
||||
exec(code)
|
||||
except SyntaxError:
|
||||
print("SyntaxError")
|
||||
test_syntax("f(*a, *b)")
|
||||
test_syntax("f(**a, **b)")
|
||||
|
||||
# from basics/sys1.py
|
||||
# uPy prints version 3.4
|
||||
import sys
|
||||
print(sys.version[:3])
|
||||
print(sys.version_info[0], sys.version_info[1])
|
7
tests/basics/python34.py.exp
Normal file
7
tests/basics/python34.py.exp
Normal file
@ -0,0 +1,7 @@
|
||||
None
|
||||
['a', 'b']
|
||||
('a', 'b') {'kw_arg': None}
|
||||
SyntaxError
|
||||
SyntaxError
|
||||
3.4
|
||||
3 4
|
@ -83,10 +83,6 @@ test_syntax("nonlocal a")
|
||||
# default except must be last
|
||||
test_syntax("try:\n a\nexcept:\n pass\nexcept:\n pass")
|
||||
|
||||
# can't have multiple * or **
|
||||
test_syntax("f(*a, *b)")
|
||||
test_syntax("f(**a, **b)")
|
||||
|
||||
# LHS of keywords must be id's
|
||||
test_syntax("f(1=2)")
|
||||
|
||||
|
@ -5,8 +5,6 @@ import sys
|
||||
print(sys.__name__)
|
||||
print(type(sys.path))
|
||||
print(type(sys.argv))
|
||||
print(sys.version[:3])
|
||||
print(sys.version_info[0], sys.version_info[1])
|
||||
print(sys.byteorder in ('little', 'big'))
|
||||
print(sys.maxsize > 100)
|
||||
print(sys.implementation.name in ('cpython', 'micropython'))
|
||||
|
@ -4,7 +4,7 @@ if hasattr(sys, 'print_exception'):
|
||||
print_exception = sys.print_exception
|
||||
else:
|
||||
import traceback
|
||||
print_exception = lambda e, f: traceback.print_exception(None, e, None, file=f)
|
||||
print_exception = lambda e, f: traceback.print_exception(None, e, sys.exc_info()[2], file=f)
|
||||
|
||||
def print_exc(e):
|
||||
buf = io.StringIO()
|
||||
|
Loading…
x
Reference in New Issue
Block a user