Commit 34f26ea8 authored by Damien George's avatar Damien George
Browse files

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.
parent 9e0a3d46
# test if eval raises SyntaxError # test if eval raises SyntaxError
try: try:
print(eval("[1, *a]")) print(eval("[1,,]"))
except SyntaxError: except SyntaxError:
print("SyntaxError") print("SyntaxError")
...@@ -23,9 +23,3 @@ def f4(*vargs, **kwargs): ...@@ -23,9 +23,3 @@ def f4(*vargs, **kwargs):
f4(*(1, 2)) f4(*(1, 2))
f4(kw_arg=3) f4(kw_arg=3)
f4(*(1, 2), 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))
# 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])
None
['a', 'b']
('a', 'b') {'kw_arg': None}
SyntaxError
SyntaxError
3.4
3 4
...@@ -83,10 +83,6 @@ test_syntax("nonlocal a") ...@@ -83,10 +83,6 @@ test_syntax("nonlocal a")
# default except must be last # default except must be last
test_syntax("try:\n a\nexcept:\n pass\nexcept:\n pass") 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 # LHS of keywords must be id's
test_syntax("f(1=2)") test_syntax("f(1=2)")
......
...@@ -5,8 +5,6 @@ import sys ...@@ -5,8 +5,6 @@ import sys
print(sys.__name__) print(sys.__name__)
print(type(sys.path)) print(type(sys.path))
print(type(sys.argv)) 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.byteorder in ('little', 'big'))
print(sys.maxsize > 100) print(sys.maxsize > 100)
print(sys.implementation.name in ('cpython', 'micropython')) print(sys.implementation.name in ('cpython', 'micropython'))
......
...@@ -4,7 +4,7 @@ if hasattr(sys, 'print_exception'): ...@@ -4,7 +4,7 @@ if hasattr(sys, 'print_exception'):
print_exception = sys.print_exception print_exception = sys.print_exception
else: else:
import traceback 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): def print_exc(e):
buf = io.StringIO() buf = io.StringIO()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment