diff options
| author | Damien George <damien@micropython.org> | 2021-05-30 09:42:27 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-05-30 13:41:37 +1000 |
| commit | 025e4b6fbc32cd3118a5519cf6a18aa04b045abe (patch) | |
| tree | e5c742abc37c46d30d1338b9ce4db399d0eb5713 | |
| parent | 486fe71c6ee3fbc4bbebf348832e88880b8a5bae (diff) | |
tests/basics: Split out literal tests that raise SyntaxWarning on CPy.
Fixes issue #7330.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | tests/basics/is_isnot.py | 10 | ||||
| -rw-r--r-- | tests/basics/is_isnot_literal.py | 13 | ||||
| -rw-r--r-- | tests/basics/is_isnot_literal.py.exp | 8 | ||||
| -rw-r--r-- | tests/basics/op_error.py | 14 | ||||
| -rw-r--r-- | tests/basics/op_error_literal.py | 18 | ||||
| -rw-r--r-- | tests/basics/op_error_literal.py.exp | 3 |
6 files changed, 42 insertions, 24 deletions
diff --git a/tests/basics/is_isnot.py b/tests/basics/is_isnot.py index 990190aa4..55459cb0a 100644 --- a/tests/basics/is_isnot.py +++ b/tests/basics/is_isnot.py @@ -1,14 +1,4 @@ -print(1 is 1) -print(1 is 2) -print(1 is not 1) -print(1 is not 2) - - print([1, 2] is [1, 2]) a = [1, 2] b = a print(b is a) - -# TODO: strings require special "is" handling, postponed -# until qstr refactor. -#print("a" is "a") diff --git a/tests/basics/is_isnot_literal.py b/tests/basics/is_isnot_literal.py new file mode 100644 index 000000000..1626fa949 --- /dev/null +++ b/tests/basics/is_isnot_literal.py @@ -0,0 +1,13 @@ +# test "is" and "is not" with literal arguments +# these raise a SyntaxWarning in CPython because the results are +# implementation dependent; see https://bugs.python.org/issue34850 + +print(1 is 1) +print(1 is 2) +print(1 is not 1) +print(1 is not 2) + +print("a" is "a") +print("a" is "b") +print("a" is not "a") +print("a" is not "b") diff --git a/tests/basics/is_isnot_literal.py.exp b/tests/basics/is_isnot_literal.py.exp new file mode 100644 index 000000000..fc4b8f812 --- /dev/null +++ b/tests/basics/is_isnot_literal.py.exp @@ -0,0 +1,8 @@ +True +False +False +True +True +False +False +True diff --git a/tests/basics/op_error.py b/tests/basics/op_error.py index 63c35db3f..98a3ab025 100644 --- a/tests/basics/op_error.py +++ b/tests/basics/op_error.py @@ -30,18 +30,10 @@ except TypeError: # unsupported subscription try: - 1[0] -except TypeError: - print('TypeError') -try: 1[0] = 1 except TypeError: print('TypeError') try: - ''[''] -except TypeError: - print('TypeError') -try: 'a'[0] = 1 except TypeError: print('TypeError') @@ -50,12 +42,6 @@ try: except TypeError: print('TypeError') -# not callable -try: - 1() -except TypeError: - print('TypeError') - # not an iterator try: next(1) diff --git a/tests/basics/op_error_literal.py b/tests/basics/op_error_literal.py new file mode 100644 index 000000000..00244ee2b --- /dev/null +++ b/tests/basics/op_error_literal.py @@ -0,0 +1,18 @@ +# test errors from bad operations with literals +# these raise a SyntaxWarning in CPython; see https://bugs.python.org/issue15248 + +# unsupported subscription +try: + 1[0] +except TypeError: + print("TypeError") +try: + ""[""] +except TypeError: + print("TypeError") + +# not callable +try: + 1() +except TypeError: + print("TypeError") diff --git a/tests/basics/op_error_literal.py.exp b/tests/basics/op_error_literal.py.exp new file mode 100644 index 000000000..a8ea4fb10 --- /dev/null +++ b/tests/basics/op_error_literal.py.exp @@ -0,0 +1,3 @@ +TypeError +TypeError +TypeError |
