diff options
Diffstat (limited to 'tests/misc')
| -rw-r--r-- | tests/misc/non_compliant.py | 25 | ||||
| -rw-r--r-- | tests/misc/non_compliant.py.exp | 3 | ||||
| -rw-r--r-- | tests/misc/print_exception.py | 9 | ||||
| -rw-r--r-- | tests/misc/recursion.py | 7 | ||||
| -rw-r--r-- | tests/misc/recursive_data.py | 13 | ||||
| -rw-r--r-- | tests/misc/recursive_data.py.exp | 1 | ||||
| -rw-r--r-- | tests/misc/recursive_iternext.py | 57 | ||||
| -rw-r--r-- | tests/misc/recursive_iternext.py.exp | 4 |
8 files changed, 37 insertions, 82 deletions
diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index 8c2f4184b..99633416a 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -124,3 +124,28 @@ try: f.x = 1 except AttributeError: print('AttributeError') + +# can't call a function type (ie make new instances of a function) +try: + type(f)() +except TypeError: + print('TypeError') + +# test when object explicitly listed at not-last position in parent tuple +# this is not compliant with CPython because of illegal MRO +class A: + def foo(self): + print('A.foo') +class B(object, A): + pass +B().foo() + +# can't assign property (or other special accessors) to already-subclassed class +class A: + pass +class B(A): + pass +try: + A.bar = property() +except AttributeError: + print('AttributeError') diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp index 9c157fd5b..3f15a1440 100644 --- a/tests/misc/non_compliant.py.exp +++ b/tests/misc/non_compliant.py.exp @@ -18,3 +18,6 @@ b'\x01\x02' b'\x01\x00' NotImplementedError AttributeError +TypeError +A.foo +AttributeError diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py index 9ab8e728b..f120fe1e1 100644 --- a/tests/misc/print_exception.py +++ b/tests/misc/print_exception.py @@ -56,3 +56,12 @@ try: f() except Exception as e: print_exc(e) + +# Test non-stream object passed as output object, only valid for uPy +if hasattr(sys, 'print_exception'): + try: + sys.print_exception(Exception, 1) + had_exception = False + except OSError: + had_exception = True + assert had_exception diff --git a/tests/misc/recursion.py b/tests/misc/recursion.py deleted file mode 100644 index 227f48396..000000000 --- a/tests/misc/recursion.py +++ /dev/null @@ -1,7 +0,0 @@ -def foo(): - foo() - -try: - foo() -except RuntimeError: - print("RuntimeError") diff --git a/tests/misc/recursive_data.py b/tests/misc/recursive_data.py deleted file mode 100644 index 3b7fa5095..000000000 --- a/tests/misc/recursive_data.py +++ /dev/null @@ -1,13 +0,0 @@ -# This tests that printing recursive data structure doesn't lead to segfault. -try: - import uio as io -except ImportError: - print("SKIP") - raise SystemExit - -l = [1, 2, 3, None] -l[-1] = l -try: - print(l, file=io.StringIO()) -except RuntimeError: - print("RuntimeError") diff --git a/tests/misc/recursive_data.py.exp b/tests/misc/recursive_data.py.exp deleted file mode 100644 index 8a2b9bfdd..000000000 --- a/tests/misc/recursive_data.py.exp +++ /dev/null @@ -1 +0,0 @@ -RuntimeError diff --git a/tests/misc/recursive_iternext.py b/tests/misc/recursive_iternext.py deleted file mode 100644 index edb5a843f..000000000 --- a/tests/misc/recursive_iternext.py +++ /dev/null @@ -1,57 +0,0 @@ -# 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. -try: - # large stack/heap, eg unix - [0] * 80000 - N = 2400 -except: - try: - # medium, eg pyboard - [0] * 10000 - N = 1000 - except: - # small, eg esp8266 - N = 100 - -try: - x = (1, 2) - for i in range(N): - x = enumerate(x) - tuple(x) -except RuntimeError: - print("RuntimeError") - -try: - x = (1, 2) - for i in range(N): - x = filter(None, x) - tuple(x) -except RuntimeError: - print("RuntimeError") - -try: - x = (1, 2) - for i in range(N): - x = map(max, x, ()) - tuple(x) -except RuntimeError: - print("RuntimeError") - -try: - x = (1, 2) - for i in range(N): - x = zip(x) - tuple(x) -except RuntimeError: - print("RuntimeError") diff --git a/tests/misc/recursive_iternext.py.exp b/tests/misc/recursive_iternext.py.exp deleted file mode 100644 index 80d1488a3..000000000 --- a/tests/misc/recursive_iternext.py.exp +++ /dev/null @@ -1,4 +0,0 @@ -RuntimeError -RuntimeError -RuntimeError -RuntimeError |
