diff --git a/tests/basics/builtin_eval_error.py b/tests/basics/builtin_eval_error.py index 3e8a8ff0d..671eedab6 100644 --- a/tests/basics/builtin_eval_error.py +++ b/tests/basics/builtin_eval_error.py @@ -1,6 +1,6 @@ # test if eval raises SyntaxError try: - print(eval("[1, *a]")) + print(eval("[1,,]")) except SyntaxError: print("SyntaxError") diff --git a/tests/basics/fun_kwvarargs.py b/tests/basics/fun_kwvarargs.py index 2b6893f24..bdc10fcf1 100644 --- a/tests/basics/fun_kwvarargs.py +++ b/tests/basics/fun_kwvarargs.py @@ -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)) diff --git a/tests/basics/python34.py b/tests/basics/python34.py new file mode 100644 index 000000000..2e9d468b2 --- /dev/null +++ b/tests/basics/python34.py @@ -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]) diff --git a/tests/basics/python34.py.exp b/tests/basics/python34.py.exp new file mode 100644 index 000000000..078c3fbb7 --- /dev/null +++ b/tests/basics/python34.py.exp @@ -0,0 +1,7 @@ +None +['a', 'b'] +('a', 'b') {'kw_arg': None} +SyntaxError +SyntaxError +3.4 +3 4 diff --git a/tests/basics/syntaxerror.py b/tests/basics/syntaxerror.py index d6a3e3043..24c3fe6e4 100644 --- a/tests/basics/syntaxerror.py +++ b/tests/basics/syntaxerror.py @@ -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)") diff --git a/tests/basics/sys1.py b/tests/basics/sys1.py index a9984576b..816c8823a 100644 --- a/tests/basics/sys1.py +++ b/tests/basics/sys1.py @@ -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')) diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py index 4e23bf154..92c9794e8 100644 --- a/tests/misc/print_exception.py +++ b/tests/misc/print_exception.py @@ -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()