From a2803b74f48849cb3a11fb492fee891044ecc1f4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 10 Jun 2017 20:03:01 +0300 Subject: [PATCH] tests/basics: Convert "sys.exit()" to "raise SystemExit". --- tests/basics/array1.py | 3 +-- tests/basics/array_add.py | 3 +-- tests/basics/array_construct.py | 3 +-- tests/basics/array_construct2.py | 3 +-- tests/basics/array_construct_endian.py | 3 +-- tests/basics/array_intbig.py | 3 +-- tests/basics/array_micropython.py | 3 +-- tests/basics/attrtuple1.py | 3 +-- tests/basics/builtin_delattr.py | 3 +-- tests/basics/builtin_help.py | 3 +-- tests/basics/builtin_minmax.py | 3 +-- tests/basics/builtin_override.py | 3 +-- tests/basics/builtin_pow3.py | 3 +-- tests/basics/builtin_pow3_intbig.py | 3 +-- tests/basics/builtin_property.py | 3 +-- tests/basics/builtin_range_attrs.py | 3 +-- tests/basics/builtin_reversed.py | 3 +-- tests/basics/builtin_sorted.py | 3 +-- tests/basics/bytearray_construct_array.py | 3 +-- tests/basics/bytearray_construct_endian.py | 3 +-- tests/basics/bytearray_slice_assign.py | 3 +-- tests/basics/bytes_add_array.py | 3 +-- tests/basics/bytes_add_endian.py | 3 +-- tests/basics/bytes_compare_array.py | 3 +-- tests/basics/bytes_construct_array.py | 3 +-- tests/basics/bytes_construct_endian.py | 3 +-- tests/basics/bytes_partition.py | 3 +-- tests/basics/class_delattr_setattr.py | 3 +-- tests/basics/class_descriptor.py | 3 +-- tests/basics/class_new.py | 3 +-- tests/basics/class_store_class.py | 3 +-- tests/basics/class_super_object.py | 3 +-- tests/basics/dict_fromkeys2.py | 3 +-- tests/basics/enumerate.py | 3 +-- tests/basics/errno1.py | 3 +-- tests/basics/filter.py | 3 +-- tests/basics/frozenset1.py | 3 +-- tests/basics/frozenset_add.py | 3 +-- tests/basics/frozenset_binop.py | 3 +-- tests/basics/frozenset_copy.py | 3 +-- tests/basics/frozenset_difference.py | 3 +-- tests/basics/frozenset_set.py | 3 +-- tests/basics/fun_error2.py | 3 +-- tests/basics/gc1.py | 3 +-- tests/basics/memoryview1.py | 3 +-- tests/basics/memoryview2.py | 3 +-- tests/basics/memoryview_gc.py | 3 +-- tests/basics/memoryview_intbig.py | 3 +-- tests/basics/namedtuple1.py | 3 +-- tests/basics/object_dict.py | 3 +-- tests/basics/object_new.py | 3 +-- tests/basics/op_error_memoryview.py | 3 +-- tests/basics/ordereddict1.py | 3 +-- tests/basics/ordereddict_eq.py | 3 +-- tests/basics/parser.py | 3 +-- tests/basics/set_type.py | 3 +-- tests/basics/slice_attrs.py | 3 +-- tests/basics/special_methods2.py | 3 +-- tests/basics/string_center.py | 3 +-- tests/basics/string_partition.py | 3 +-- tests/basics/string_rpartition.py | 3 +-- tests/basics/string_splitlines.py | 3 +-- tests/basics/struct1.py | 3 +-- tests/basics/struct1_intbig.py | 3 +-- tests/basics/struct2.py | 3 +-- tests/basics/struct_micropython.py | 3 +-- tests/basics/subclass_classmethod.py | 3 +-- tests/basics/sys1.py | 2 +- tests/basics/zip.py | 3 +-- 69 files changed, 69 insertions(+), 137 deletions(-) diff --git a/tests/basics/array1.py b/tests/basics/array1.py index 43f775b797..bad879035c 100644 --- a/tests/basics/array1.py +++ b/tests/basics/array1.py @@ -1,9 +1,8 @@ try: import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit a = array.array('B', [1, 2, 3]) print(a, len(a)) diff --git a/tests/basics/array_add.py b/tests/basics/array_add.py index 41cd77b428..76ce59f761 100644 --- a/tests/basics/array_add.py +++ b/tests/basics/array_add.py @@ -2,9 +2,8 @@ try: import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit a1 = array.array('I', [1]) a2 = array.array('I', [2]) diff --git a/tests/basics/array_construct.py b/tests/basics/array_construct.py index cafa57784c..2221de9906 100644 --- a/tests/basics/array_construct.py +++ b/tests/basics/array_construct.py @@ -3,9 +3,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # tuple, list print(array('b', (1, 2))) diff --git a/tests/basics/array_construct2.py b/tests/basics/array_construct2.py index d1c1a6c70b..c305b7f011 100644 --- a/tests/basics/array_construct2.py +++ b/tests/basics/array_construct2.py @@ -1,9 +1,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # construct from something with unknown length (requires generators) print(array('i', (i for i in range(10)))) diff --git a/tests/basics/array_construct_endian.py b/tests/basics/array_construct_endian.py index bf34b05d15..990d7b1ea0 100644 --- a/tests/basics/array_construct_endian.py +++ b/tests/basics/array_construct_endian.py @@ -3,9 +3,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # raw copy from bytes, bytearray print(array('h', b'12')) diff --git a/tests/basics/array_intbig.py b/tests/basics/array_intbig.py index 4a3b2a0d42..5702a8ae63 100644 --- a/tests/basics/array_intbig.py +++ b/tests/basics/array_intbig.py @@ -3,9 +3,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(array('L', [0, 2**32-1])) print(array('l', [-2**31, 0, 2**31-1])) diff --git a/tests/basics/array_micropython.py b/tests/basics/array_micropython.py index 0c1df0923b..e26ad7ae96 100644 --- a/tests/basics/array_micropython.py +++ b/tests/basics/array_micropython.py @@ -2,9 +2,8 @@ try: import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # arrays of objects a = array.array('O') diff --git a/tests/basics/attrtuple1.py b/tests/basics/attrtuple1.py index 597bfc2a32..78a0fbed1b 100644 --- a/tests/basics/attrtuple1.py +++ b/tests/basics/attrtuple1.py @@ -8,9 +8,8 @@ t = sys.implementation try: t.name except AttributeError: - import sys print("SKIP") - sys.exit() + raise SystemExit # test printing of attrtuple diff --git a/tests/basics/builtin_delattr.py b/tests/basics/builtin_delattr.py index 9b38837e44..65bd0f210d 100644 --- a/tests/basics/builtin_delattr.py +++ b/tests/basics/builtin_delattr.py @@ -2,9 +2,8 @@ try: delattr except: - import sys print("SKIP") - sys.exit() + raise SystemExit class A: pass a = A() diff --git a/tests/basics/builtin_help.py b/tests/basics/builtin_help.py index d554f308d9..6ec39653fe 100644 --- a/tests/basics/builtin_help.py +++ b/tests/basics/builtin_help.py @@ -4,8 +4,7 @@ try: help except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit help() # no args help(help) # help for a function diff --git a/tests/basics/builtin_minmax.py b/tests/basics/builtin_minmax.py index a925b3fe92..184398e641 100644 --- a/tests/basics/builtin_minmax.py +++ b/tests/basics/builtin_minmax.py @@ -3,9 +3,8 @@ try: min max except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(min(0,1)) print(min(1,0)) diff --git a/tests/basics/builtin_override.py b/tests/basics/builtin_override.py index f3632e59a7..9f91341edd 100644 --- a/tests/basics/builtin_override.py +++ b/tests/basics/builtin_override.py @@ -6,9 +6,8 @@ import builtins try: builtins.abs = lambda x: x + 1 except AttributeError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(abs(1)) diff --git a/tests/basics/builtin_pow3.py b/tests/basics/builtin_pow3.py index dec7253bbd..69b57e5484 100644 --- a/tests/basics/builtin_pow3.py +++ b/tests/basics/builtin_pow3.py @@ -4,9 +4,8 @@ try: print(pow(3, 4, 7)) except NotImplementedError: - import sys print("SKIP") - sys.exit() + raise SystemExit # 3 arg pow is defined to only work on integers try: diff --git a/tests/basics/builtin_pow3_intbig.py b/tests/basics/builtin_pow3_intbig.py index 9f482cbde7..bedc8b36b7 100644 --- a/tests/basics/builtin_pow3_intbig.py +++ b/tests/basics/builtin_pow3_intbig.py @@ -4,9 +4,8 @@ try: print(pow(3, 4, 7)) except NotImplementedError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(pow(555557, 1000002, 1000003)) diff --git a/tests/basics/builtin_property.py b/tests/basics/builtin_property.py index ff4ff073c4..89c3d49364 100644 --- a/tests/basics/builtin_property.py +++ b/tests/basics/builtin_property.py @@ -2,9 +2,8 @@ try: property except: - import sys print("SKIP") - sys.exit() + raise SystemExit # create a property object explicitly property() diff --git a/tests/basics/builtin_range_attrs.py b/tests/basics/builtin_range_attrs.py index 9327c802a5..05d666d139 100644 --- a/tests/basics/builtin_range_attrs.py +++ b/tests/basics/builtin_range_attrs.py @@ -3,9 +3,8 @@ try: range(0).start except AttributeError: - import sys print("SKIP") - sys.exit() + raise SystemExit # attrs print(range(1, 2, 3).start) diff --git a/tests/basics/builtin_reversed.py b/tests/basics/builtin_reversed.py index 59e9c78219..f43505a8bf 100644 --- a/tests/basics/builtin_reversed.py +++ b/tests/basics/builtin_reversed.py @@ -2,9 +2,8 @@ try: reversed except: - import sys print("SKIP") - sys.exit() + raise SystemExit # list print(list(reversed([]))) diff --git a/tests/basics/builtin_sorted.py b/tests/basics/builtin_sorted.py index 68855b61ba..6435f86d0e 100644 --- a/tests/basics/builtin_sorted.py +++ b/tests/basics/builtin_sorted.py @@ -3,9 +3,8 @@ try: sorted set except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(sorted(set(range(100)))) print(sorted(set(range(100)), key=lambda x: x + 100*(x % 2))) diff --git a/tests/basics/bytearray_construct_array.py b/tests/basics/bytearray_construct_array.py index 6d45cafda3..bde5fa08bd 100644 --- a/tests/basics/bytearray_construct_array.py +++ b/tests/basics/bytearray_construct_array.py @@ -2,9 +2,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # arrays print(bytearray(array('b', [1, 2]))) diff --git a/tests/basics/bytearray_construct_endian.py b/tests/basics/bytearray_construct_endian.py index f68f9b89d1..0002f19c5f 100644 --- a/tests/basics/bytearray_construct_endian.py +++ b/tests/basics/bytearray_construct_endian.py @@ -2,9 +2,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # arrays print(bytearray(array('h', [1, 2]))) diff --git a/tests/basics/bytearray_slice_assign.py b/tests/basics/bytearray_slice_assign.py index c4b5c43e33..48f5938a58 100644 --- a/tests/basics/bytearray_slice_assign.py +++ b/tests/basics/bytearray_slice_assign.py @@ -2,8 +2,7 @@ try: bytearray()[:] = bytearray() except TypeError: print("SKIP") - import sys - sys.exit() + raise SystemExit # test slices; only 2 argument version supported by Micro Python at the moment x = bytearray(range(10)) diff --git a/tests/basics/bytes_add_array.py b/tests/basics/bytes_add_array.py index 2b8cbccef5..b17556d83c 100644 --- a/tests/basics/bytes_add_array.py +++ b/tests/basics/bytes_add_array.py @@ -2,9 +2,8 @@ try: import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # should be byteorder-neutral print(b"123" + array.array('h', [0x1515])) diff --git a/tests/basics/bytes_add_endian.py b/tests/basics/bytes_add_endian.py index 1bbd0f2c3a..8cfffa7b6a 100644 --- a/tests/basics/bytes_add_endian.py +++ b/tests/basics/bytes_add_endian.py @@ -2,8 +2,7 @@ try: import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(b"123" + array.array('i', [1])) diff --git a/tests/basics/bytes_compare_array.py b/tests/basics/bytes_compare_array.py index ad41d1d375..ad378de70c 100644 --- a/tests/basics/bytes_compare_array.py +++ b/tests/basics/bytes_compare_array.py @@ -1,9 +1,8 @@ try: import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(array.array('b', [1, 2]) in b'\x01\x02\x03') # CPython gives False here diff --git a/tests/basics/bytes_construct_array.py b/tests/basics/bytes_construct_array.py index 72c2d0c585..453eb59010 100644 --- a/tests/basics/bytes_construct_array.py +++ b/tests/basics/bytes_construct_array.py @@ -2,9 +2,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # arrays print(bytes(array('b', [1, 2]))) diff --git a/tests/basics/bytes_construct_endian.py b/tests/basics/bytes_construct_endian.py index 77e0eaaa56..cf1a9f408f 100644 --- a/tests/basics/bytes_construct_endian.py +++ b/tests/basics/bytes_construct_endian.py @@ -3,9 +3,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit # arrays print(bytes(array('h', [1, 2]))) diff --git a/tests/basics/bytes_partition.py b/tests/basics/bytes_partition.py index 7d3ffaaaaa..5b503f5443 100644 --- a/tests/basics/bytes_partition.py +++ b/tests/basics/bytes_partition.py @@ -2,8 +2,7 @@ try: str.partition except AttributeError: print("SKIP") - import sys - sys.exit() + raise SystemExit print(b"asdf".partition(b'g')) print(b"asdf".partition(b'a')) diff --git a/tests/basics/class_delattr_setattr.py b/tests/basics/class_delattr_setattr.py index 0d061aee68..190b4875b9 100644 --- a/tests/basics/class_delattr_setattr.py +++ b/tests/basics/class_delattr_setattr.py @@ -6,9 +6,8 @@ try: def __delattr__(self, attr): pass del Test().noexist except AttributeError: - import sys print('SKIP') - sys.exit() + raise SystemExit # this class just prints the calls to see if they were executed class A(): diff --git a/tests/basics/class_descriptor.py b/tests/basics/class_descriptor.py index 7f295f071e..eb88ba7b9c 100644 --- a/tests/basics/class_descriptor.py +++ b/tests/basics/class_descriptor.py @@ -21,9 +21,8 @@ m = Main() try: m.__class__ except AttributeError: - import sys print("SKIP") - sys.exit() + raise SystemExit r = m.Forward if 'Descriptor' in repr(r.__class__): diff --git a/tests/basics/class_new.py b/tests/basics/class_new.py index 0198456b24..9a7072ad03 100644 --- a/tests/basics/class_new.py +++ b/tests/basics/class_new.py @@ -3,9 +3,8 @@ try: # nothing to test. object.__new__ except AttributeError: - import sys print("SKIP") - sys.exit() + raise SystemExit class A: def __new__(cls): print("A.__new__") diff --git a/tests/basics/class_store_class.py b/tests/basics/class_store_class.py index 00a2915869..797f88f852 100644 --- a/tests/basics/class_store_class.py +++ b/tests/basics/class_store_class.py @@ -8,9 +8,8 @@ except ImportError: try: from ucollections import namedtuple except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit _DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ]) diff --git a/tests/basics/class_super_object.py b/tests/basics/class_super_object.py index a841d34abb..1fddbb38fd 100644 --- a/tests/basics/class_super_object.py +++ b/tests/basics/class_super_object.py @@ -4,9 +4,8 @@ try: # nothing to test. object.__init__ except AttributeError: - import sys print("SKIP") - sys.exit() + raise SystemExit class Test(object): def __init__(self): diff --git a/tests/basics/dict_fromkeys2.py b/tests/basics/dict_fromkeys2.py index 7ea0cc5b36..dce1e8ef5a 100644 --- a/tests/basics/dict_fromkeys2.py +++ b/tests/basics/dict_fromkeys2.py @@ -1,9 +1,8 @@ try: reversed except: - import sys print("SKIP") - sys.exit() + raise SystemExit # argument to fromkeys has no __len__ d = dict.fromkeys(reversed(range(1))) diff --git a/tests/basics/enumerate.py b/tests/basics/enumerate.py index 3cc1350a0f..4f8239bf72 100644 --- a/tests/basics/enumerate.py +++ b/tests/basics/enumerate.py @@ -1,9 +1,8 @@ try: enumerate except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(list(enumerate([]))) print(list(enumerate([1, 2, 3]))) diff --git a/tests/basics/errno1.py b/tests/basics/errno1.py index eae1bbe1b4..63930b767f 100644 --- a/tests/basics/errno1.py +++ b/tests/basics/errno1.py @@ -4,8 +4,7 @@ try: import uerrno except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit # check that constants exist and are integers print(type(uerrno.EIO)) diff --git a/tests/basics/filter.py b/tests/basics/filter.py index d0b36733c3..c6d97cf9b5 100644 --- a/tests/basics/filter.py +++ b/tests/basics/filter.py @@ -1,9 +1,8 @@ try: filter except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(list(filter(lambda x: x & 1, range(-3, 4)))) print(list(filter(None, range(-3, 4)))) diff --git a/tests/basics/frozenset1.py b/tests/basics/frozenset1.py index 7a4a335401..7bec24c295 100644 --- a/tests/basics/frozenset1.py +++ b/tests/basics/frozenset1.py @@ -4,8 +4,7 @@ try: frozenset except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit s = frozenset() print(s) diff --git a/tests/basics/frozenset_add.py b/tests/basics/frozenset_add.py index 415a8c2e13..fe24fbaf1d 100644 --- a/tests/basics/frozenset_add.py +++ b/tests/basics/frozenset_add.py @@ -2,8 +2,7 @@ try: frozenset except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit s = frozenset({1, 2, 3, 4}) try: diff --git a/tests/basics/frozenset_binop.py b/tests/basics/frozenset_binop.py index 5cc07e9e15..61af07a239 100644 --- a/tests/basics/frozenset_binop.py +++ b/tests/basics/frozenset_binop.py @@ -2,8 +2,7 @@ try: frozenset except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit sets = [ frozenset(), frozenset({1}), frozenset({1, 2}), frozenset({1, 2, 3}), frozenset({2, 3}), diff --git a/tests/basics/frozenset_copy.py b/tests/basics/frozenset_copy.py index 92e115d346..c90f541a13 100644 --- a/tests/basics/frozenset_copy.py +++ b/tests/basics/frozenset_copy.py @@ -2,8 +2,7 @@ try: frozenset except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit s = frozenset({1, 2, 3, 4}) t = s.copy() diff --git a/tests/basics/frozenset_difference.py b/tests/basics/frozenset_difference.py index 3d142f9595..bc8b9c21cc 100644 --- a/tests/basics/frozenset_difference.py +++ b/tests/basics/frozenset_difference.py @@ -2,8 +2,7 @@ try: frozenset except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit l = [1, 2, 3, 4] s = frozenset(l) diff --git a/tests/basics/frozenset_set.py b/tests/basics/frozenset_set.py index b334694b5b..3bf456acfd 100644 --- a/tests/basics/frozenset_set.py +++ b/tests/basics/frozenset_set.py @@ -2,8 +2,7 @@ try: frozenset except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit # Examples from https://docs.python.org/3/library/stdtypes.html#set # "Instances of set are compared to instances of frozenset based on their diff --git a/tests/basics/fun_error2.py b/tests/basics/fun_error2.py index c4d2c0b64d..2a00396e65 100644 --- a/tests/basics/fun_error2.py +++ b/tests/basics/fun_error2.py @@ -3,8 +3,7 @@ try: enumerate except: print("SKIP") - import sys - sys.exit() + raise SystemExit def test_exc(code, exc): try: diff --git a/tests/basics/gc1.py b/tests/basics/gc1.py index be6c6faed2..dcbe0bfcf6 100644 --- a/tests/basics/gc1.py +++ b/tests/basics/gc1.py @@ -4,8 +4,7 @@ try: import gc except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit print(gc.isenabled()) gc.disable() diff --git a/tests/basics/memoryview1.py b/tests/basics/memoryview1.py index a771acdda9..c4cc6ffab7 100644 --- a/tests/basics/memoryview1.py +++ b/tests/basics/memoryview1.py @@ -2,9 +2,8 @@ try: memoryview except: - import sys print("SKIP") - sys.exit() + raise SystemExit # test reading from bytes b = b'1234' diff --git a/tests/basics/memoryview2.py b/tests/basics/memoryview2.py index 4b5af852b2..06a7be59fd 100644 --- a/tests/basics/memoryview2.py +++ b/tests/basics/memoryview2.py @@ -3,9 +3,8 @@ try: from array import array memoryview except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(list(memoryview(b'\x7f\x80\x81\xff'))) print(list(memoryview(array('b', [0x7f, -0x80])))) diff --git a/tests/basics/memoryview_gc.py b/tests/basics/memoryview_gc.py index 9d4857e362..d366cbbb15 100644 --- a/tests/basics/memoryview_gc.py +++ b/tests/basics/memoryview_gc.py @@ -2,9 +2,8 @@ try: memoryview except: - import sys print("SKIP") - sys.exit() + raise SystemExit b = bytearray(10) m = memoryview(b)[1:] diff --git a/tests/basics/memoryview_intbig.py b/tests/basics/memoryview_intbig.py index 180f15d186..a76d9cbec7 100644 --- a/tests/basics/memoryview_intbig.py +++ b/tests/basics/memoryview_intbig.py @@ -3,9 +3,8 @@ try: from array import array memoryview except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(list(memoryview(array('i', [0x7f000000, -0x80000000])))) print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff])))) diff --git a/tests/basics/namedtuple1.py b/tests/basics/namedtuple1.py index 70372f7cab..b9a007240c 100644 --- a/tests/basics/namedtuple1.py +++ b/tests/basics/namedtuple1.py @@ -4,9 +4,8 @@ try: except ImportError: from ucollections import namedtuple except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit T = namedtuple("Tup", ["foo", "bar"]) # CPython prints fully qualified name, what we don't bother to do so far diff --git a/tests/basics/object_dict.py b/tests/basics/object_dict.py index e6fb7b3d9c..7bf7094e3a 100644 --- a/tests/basics/object_dict.py +++ b/tests/basics/object_dict.py @@ -1,4 +1,3 @@ -import sys class Foo: @@ -9,6 +8,6 @@ class Foo: o = Foo() if not hasattr(o, "__dict__"): print("SKIP") - sys.exit() + raise SystemExit print(o.__dict__ == {'a': 1, 'b': 'bar'}) diff --git a/tests/basics/object_new.py b/tests/basics/object_new.py index 568feccda4..a9c9482cbb 100644 --- a/tests/basics/object_new.py +++ b/tests/basics/object_new.py @@ -7,9 +7,8 @@ try: # nothing to test. object.__new__ except AttributeError: - import sys print("SKIP") - sys.exit() + raise SystemExit class Foo: diff --git a/tests/basics/op_error_memoryview.py b/tests/basics/op_error_memoryview.py index 658ededc80..8d4403f777 100644 --- a/tests/basics/op_error_memoryview.py +++ b/tests/basics/op_error_memoryview.py @@ -2,9 +2,8 @@ try: memoryview except: - import sys print("SKIP") - sys.exit() + raise SystemExit def test_exc(code, exc): try: diff --git a/tests/basics/ordereddict1.py b/tests/basics/ordereddict1.py index 7147968c58..d1633f0bb0 100644 --- a/tests/basics/ordereddict1.py +++ b/tests/basics/ordereddict1.py @@ -5,8 +5,7 @@ except ImportError: from ucollections import OrderedDict except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit d = OrderedDict([(10, 20), ("b", 100), (1, 2)]) print(len(d)) diff --git a/tests/basics/ordereddict_eq.py b/tests/basics/ordereddict_eq.py index 2746608772..c69daf8802 100644 --- a/tests/basics/ordereddict_eq.py +++ b/tests/basics/ordereddict_eq.py @@ -5,8 +5,7 @@ except ImportError: from ucollections import OrderedDict except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit x = OrderedDict() y = OrderedDict() diff --git a/tests/basics/parser.py b/tests/basics/parser.py index 8fb2a49bf9..626b67ad7a 100644 --- a/tests/basics/parser.py +++ b/tests/basics/parser.py @@ -4,8 +4,7 @@ try: compile except NameError: print("SKIP") - import sys - sys.exit() + raise SystemExit # completely empty string # uPy and CPy differ for this case diff --git a/tests/basics/set_type.py b/tests/basics/set_type.py index d790fa062e..787a99e815 100644 --- a/tests/basics/set_type.py +++ b/tests/basics/set_type.py @@ -5,9 +5,8 @@ try: set except NameError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(set) diff --git a/tests/basics/slice_attrs.py b/tests/basics/slice_attrs.py index 67456ff8e6..e85ead4ba9 100644 --- a/tests/basics/slice_attrs.py +++ b/tests/basics/slice_attrs.py @@ -8,9 +8,8 @@ class A: try: t = A()[1:2] except: - import sys print("SKIP") - sys.exit() + raise SystemExit A()[1:2:3] diff --git a/tests/basics/special_methods2.py b/tests/basics/special_methods2.py index 3623b30dcc..ba7cf27cda 100644 --- a/tests/basics/special_methods2.py +++ b/tests/basics/special_methods2.py @@ -100,9 +100,8 @@ cud2 = Cud() try: +cud1 except TypeError: - import sys print("SKIP") - sys.exit() + raise SystemExit # the following require MICROPY_PY_ALL_SPECIAL_METHODS +cud1 diff --git a/tests/basics/string_center.py b/tests/basics/string_center.py index a2739201ac..40e8af4b8d 100644 --- a/tests/basics/string_center.py +++ b/tests/basics/string_center.py @@ -1,9 +1,8 @@ try: str.center except: - import sys print("SKIP") - sys.exit() + raise SystemExit print("foo".center(0)) print("foo".center(1)) diff --git a/tests/basics/string_partition.py b/tests/basics/string_partition.py index b3b2f0907d..bc36388fde 100644 --- a/tests/basics/string_partition.py +++ b/tests/basics/string_partition.py @@ -2,8 +2,7 @@ try: str.partition except AttributeError: print("SKIP") - import sys - sys.exit() + raise SystemExit print("asdf".partition('g')) print("asdf".partition('a')) diff --git a/tests/basics/string_rpartition.py b/tests/basics/string_rpartition.py index 84e0031fb0..6d65dfaf21 100644 --- a/tests/basics/string_rpartition.py +++ b/tests/basics/string_rpartition.py @@ -2,8 +2,7 @@ try: str.partition except AttributeError: print("SKIP") - import sys - sys.exit() + raise SystemExit print("asdf".rpartition('g')) print("asdf".rpartition('a')) diff --git a/tests/basics/string_splitlines.py b/tests/basics/string_splitlines.py index 1d08f6e6d7..c4c3fcb804 100644 --- a/tests/basics/string_splitlines.py +++ b/tests/basics/string_splitlines.py @@ -3,9 +3,8 @@ try: str.splitlines except: - import sys print("SKIP") - sys.exit() + raise SystemExit # test \n as newline print("foo\nbar".splitlines()) diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py index bb6877c785..a442beb1e5 100644 --- a/tests/basics/struct1.py +++ b/tests/basics/struct1.py @@ -4,9 +4,8 @@ except: try: import struct except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(struct.calcsize("