Skip to content

Commit 34f26ea

Browse files
committed
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.
1 parent 9e0a3d4 commit 34f26ea

File tree

7 files changed

+35
-14
lines changed

7 files changed

+35
-14
lines changed

tests/basics/builtin_eval_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# test if eval raises SyntaxError
22

33
try:
4-
print(eval("[1, *a]"))
4+
print(eval("[1,,]"))
55
except SyntaxError:
66
print("SyntaxError")

tests/basics/fun_kwvarargs.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,3 @@ def f4(*vargs, **kwargs):
2323
f4(*(1, 2))
2424
f4(kw_arg=3)
2525
f4(*(1, 2), kw_arg=3)
26-
27-
# test evaluation order of arguments (in CPy 3.4 it's actually backwards)
28-
def print_ret(x):
29-
print(x)
30-
return x
31-
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))

tests/basics/python34.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# tests that differ when running under Python 3.4 vs 3.5
2+
3+
# from basics/fun_kwvarargs.py
4+
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
5+
def f4(*vargs, **kwargs):
6+
print(vargs, kwargs)
7+
def print_ret(x):
8+
print(x)
9+
return x
10+
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
11+
12+
# from basics/syntaxerror.py
13+
# can't have multiple * or ** (in 3.5 we can)
14+
def test_syntax(code):
15+
try:
16+
exec(code)
17+
except SyntaxError:
18+
print("SyntaxError")
19+
test_syntax("f(*a, *b)")
20+
test_syntax("f(**a, **b)")
21+
22+
# from basics/sys1.py
23+
# uPy prints version 3.4
24+
import sys
25+
print(sys.version[:3])
26+
print(sys.version_info[0], sys.version_info[1])

tests/basics/python34.py.exp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
None
2+
['a', 'b']
3+
('a', 'b') {'kw_arg': None}
4+
SyntaxError
5+
SyntaxError
6+
3.4
7+
3 4

tests/basics/syntaxerror.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def test_syntax(code):
8383
# default except must be last
8484
test_syntax("try:\n a\nexcept:\n pass\nexcept:\n pass")
8585

86-
# can't have multiple * or **
87-
test_syntax("f(*a, *b)")
88-
test_syntax("f(**a, **b)")
89-
9086
# LHS of keywords must be id's
9187
test_syntax("f(1=2)")
9288

tests/basics/sys1.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
print(sys.__name__)
66
print(type(sys.path))
77
print(type(sys.argv))
8-
print(sys.version[:3])
9-
print(sys.version_info[0], sys.version_info[1])
108
print(sys.byteorder in ('little', 'big'))
119
print(sys.maxsize > 100)
1210
print(sys.implementation.name in ('cpython', 'micropython'))

tests/misc/print_exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
print_exception = sys.print_exception
55
else:
66
import traceback
7-
print_exception = lambda e, f: traceback.print_exception(None, e, None, file=f)
7+
print_exception = lambda e, f: traceback.print_exception(None, e, sys.exc_info()[2], file=f)
88

99
def print_exc(e):
1010
buf = io.StringIO()

0 commit comments

Comments
 (0)