Skip to content

Commit 025e4b6

Browse files
committed
tests/basics: Split out literal tests that raise SyntaxWarning on CPy.
Fixes issue adafruit#7330. Signed-off-by: Damien George <damien@micropython.org>
1 parent 486fe71 commit 025e4b6

6 files changed

Lines changed: 42 additions & 24 deletions

File tree

tests/basics/is_isnot.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
print(1 is 1)
2-
print(1 is 2)
3-
print(1 is not 1)
4-
print(1 is not 2)
5-
6-
71
print([1, 2] is [1, 2])
82
a = [1, 2]
93
b = a
104
print(b is a)
11-
12-
# TODO: strings require special "is" handling, postponed
13-
# until qstr refactor.
14-
#print("a" is "a")

tests/basics/is_isnot_literal.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# test "is" and "is not" with literal arguments
2+
# these raise a SyntaxWarning in CPython because the results are
3+
# implementation dependent; see https://bugs.python.org/issue34850
4+
5+
print(1 is 1)
6+
print(1 is 2)
7+
print(1 is not 1)
8+
print(1 is not 2)
9+
10+
print("a" is "a")
11+
print("a" is "b")
12+
print("a" is not "a")
13+
print("a" is not "b")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
True
2+
False
3+
False
4+
True
5+
True
6+
False
7+
False
8+
True

tests/basics/op_error.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,10 @@
2929
print('TypeError')
3030

3131
# unsupported subscription
32-
try:
33-
1[0]
34-
except TypeError:
35-
print('TypeError')
3632
try:
3733
1[0] = 1
3834
except TypeError:
3935
print('TypeError')
40-
try:
41-
''['']
42-
except TypeError:
43-
print('TypeError')
4436
try:
4537
'a'[0] = 1
4638
except TypeError:
@@ -50,12 +42,6 @@
5042
except TypeError:
5143
print('TypeError')
5244

53-
# not callable
54-
try:
55-
1()
56-
except TypeError:
57-
print('TypeError')
58-
5945
# not an iterator
6046
try:
6147
next(1)

tests/basics/op_error_literal.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# test errors from bad operations with literals
2+
# these raise a SyntaxWarning in CPython; see https://bugs.python.org/issue15248
3+
4+
# unsupported subscription
5+
try:
6+
1[0]
7+
except TypeError:
8+
print("TypeError")
9+
try:
10+
""[""]
11+
except TypeError:
12+
print("TypeError")
13+
14+
# not callable
15+
try:
16+
1()
17+
except TypeError:
18+
print("TypeError")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TypeError
2+
TypeError
3+
TypeError

0 commit comments

Comments
 (0)