diff options
Diffstat (limited to 'tests/misc')
| -rw-r--r-- | tests/misc/non_compliant.py | 16 | ||||
| -rw-r--r-- | tests/misc/non_compliant.py.exp | 1 | ||||
| -rw-r--r-- | tests/misc/print_exception.py | 21 | ||||
| -rw-r--r-- | tests/misc/recursive_data.py | 6 | ||||
| -rw-r--r-- | tests/misc/recursive_iternext.py | 9 | ||||
| -rw-r--r-- | tests/misc/sys_exc_info.py | 2 |
6 files changed, 48 insertions, 7 deletions
diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index e8ec74b5d..b4c90e9fc 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -1,7 +1,11 @@ # tests for things that are not implemented, or have non-compliant behaviour -import array -import ustruct +try: + import array + import ustruct +except ImportError: + print("SKIP") + raise SystemExit # when super can't find self try: @@ -124,3 +128,11 @@ try: bytearray(4)[0:1] = [1, 2] except NotImplementedError: print('NotImplementedError') + +# can't assign attributes to a function +def f(): + pass +try: + f.x = 1 +except AttributeError: + print('AttributeError') diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp index caa5c4569..ba5590acc 100644 --- a/tests/misc/non_compliant.py.exp +++ b/tests/misc/non_compliant.py.exp @@ -19,3 +19,4 @@ NotImplementedError b'\x01\x02' b'\x01\x00' NotImplementedError +AttributeError diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py index 9baac713e..9ab8e728b 100644 --- a/tests/misc/print_exception.py +++ b/tests/misc/print_exception.py @@ -1,8 +1,13 @@ +import sys try: - import uio as io + try: + import uio as io + except ImportError: + import io except ImportError: - import io -import sys + print("SKIP") + raise SystemExit + if hasattr(sys, 'print_exception'): print_exception = sys.print_exception else: @@ -41,3 +46,13 @@ try: except Exception as e: print('caught') print_exc(e) + +# Here we have a function with lots of bytecode generated for a single source-line, and +# there is an error right at the end of the bytecode. It should report the correct line. +def f(): + f([1, 2], [1, 2], [1, 2], {1:1, 1:1, 1:1, 1:1, 1:1, 1:1, 1:X}) + return 1 +try: + f() +except Exception as e: + print_exc(e) diff --git a/tests/misc/recursive_data.py b/tests/misc/recursive_data.py index 0de93acb8..3b7fa5095 100644 --- a/tests/misc/recursive_data.py +++ b/tests/misc/recursive_data.py @@ -1,5 +1,9 @@ # This tests that printing recursive data structure doesn't lead to segfault. -import uio as io +try: + import uio as io +except ImportError: + print("SKIP") + raise SystemExit l = [1, 2, 3, None] l[-1] = l diff --git a/tests/misc/recursive_iternext.py b/tests/misc/recursive_iternext.py index 025fa425b..edb5a843f 100644 --- a/tests/misc/recursive_iternext.py +++ b/tests/misc/recursive_iternext.py @@ -1,4 +1,13 @@ # This tests that recursion with iternext doesn't lead to segfault. +try: + enumerate + filter + map + max + zip +except: + print("SKIP") + raise SystemExit # We need to pick an N that is large enough to hit the recursion # limit, but not too large that we run out of heap memory. diff --git a/tests/misc/sys_exc_info.py b/tests/misc/sys_exc_info.py index de5b82562..4bb2c61e8 100644 --- a/tests/misc/sys_exc_info.py +++ b/tests/misc/sys_exc_info.py @@ -3,7 +3,7 @@ try: sys.exc_info except: print("SKIP") - sys.exit() + raise SystemExit def f(): print(sys.exc_info()[0:2]) |
