tests/basics: Convert "sys.exit()" to "raise SystemExit".

This commit is contained in:
Paul Sokolovsky 2017-06-10 20:03:01 +03:00
parent 0161939ed1
commit a2803b74f4
69 changed files with 69 additions and 137 deletions

View File

@ -1,9 +1,8 @@
try: try:
import array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
a = array.array('B', [1, 2, 3]) a = array.array('B', [1, 2, 3])
print(a, len(a)) print(a, len(a))

View File

@ -2,9 +2,8 @@
try: try:
import array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
a1 = array.array('I', [1]) a1 = array.array('I', [1])
a2 = array.array('I', [2]) a2 = array.array('I', [2])

View File

@ -3,9 +3,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# tuple, list # tuple, list
print(array('b', (1, 2))) print(array('b', (1, 2)))

View File

@ -1,9 +1,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# construct from something with unknown length (requires generators) # construct from something with unknown length (requires generators)
print(array('i', (i for i in range(10)))) print(array('i', (i for i in range(10))))

View File

@ -3,9 +3,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# raw copy from bytes, bytearray # raw copy from bytes, bytearray
print(array('h', b'12')) print(array('h', b'12'))

View File

@ -3,9 +3,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(array('L', [0, 2**32-1])) print(array('L', [0, 2**32-1]))
print(array('l', [-2**31, 0, 2**31-1])) print(array('l', [-2**31, 0, 2**31-1]))

View File

@ -2,9 +2,8 @@
try: try:
import array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# arrays of objects # arrays of objects
a = array.array('O') a = array.array('O')

View File

@ -8,9 +8,8 @@ t = sys.implementation
try: try:
t.name t.name
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# test printing of attrtuple # test printing of attrtuple

View File

@ -2,9 +2,8 @@
try: try:
delattr delattr
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
class A: pass class A: pass
a = A() a = A()

View File

@ -4,8 +4,7 @@ try:
help help
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
help() # no args help() # no args
help(help) # help for a function help(help) # help for a function

View File

@ -3,9 +3,8 @@ try:
min min
max max
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(min(0,1)) print(min(0,1))
print(min(1,0)) print(min(1,0))

View File

@ -6,9 +6,8 @@ import builtins
try: try:
builtins.abs = lambda x: x + 1 builtins.abs = lambda x: x + 1
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(abs(1)) print(abs(1))

View File

@ -4,9 +4,8 @@
try: try:
print(pow(3, 4, 7)) print(pow(3, 4, 7))
except NotImplementedError: except NotImplementedError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# 3 arg pow is defined to only work on integers # 3 arg pow is defined to only work on integers
try: try:

View File

@ -4,9 +4,8 @@
try: try:
print(pow(3, 4, 7)) print(pow(3, 4, 7))
except NotImplementedError: except NotImplementedError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(pow(555557, 1000002, 1000003)) print(pow(555557, 1000002, 1000003))

View File

@ -2,9 +2,8 @@
try: try:
property property
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# create a property object explicitly # create a property object explicitly
property() property()

View File

@ -3,9 +3,8 @@
try: try:
range(0).start range(0).start
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# attrs # attrs
print(range(1, 2, 3).start) print(range(1, 2, 3).start)

View File

@ -2,9 +2,8 @@
try: try:
reversed reversed
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# list # list
print(list(reversed([]))) print(list(reversed([])))

View File

@ -3,9 +3,8 @@ try:
sorted sorted
set set
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(sorted(set(range(100)))) print(sorted(set(range(100))))
print(sorted(set(range(100)), key=lambda x: x + 100*(x % 2))) print(sorted(set(range(100)), key=lambda x: x + 100*(x % 2)))

View File

@ -2,9 +2,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# arrays # arrays
print(bytearray(array('b', [1, 2]))) print(bytearray(array('b', [1, 2])))

View File

@ -2,9 +2,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# arrays # arrays
print(bytearray(array('h', [1, 2]))) print(bytearray(array('h', [1, 2])))

View File

@ -2,8 +2,7 @@ try:
bytearray()[:] = bytearray() bytearray()[:] = bytearray()
except TypeError: except TypeError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
# test slices; only 2 argument version supported by Micro Python at the moment # test slices; only 2 argument version supported by Micro Python at the moment
x = bytearray(range(10)) x = bytearray(range(10))

View File

@ -2,9 +2,8 @@
try: try:
import array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# should be byteorder-neutral # should be byteorder-neutral
print(b"123" + array.array('h', [0x1515])) print(b"123" + array.array('h', [0x1515]))

View File

@ -2,8 +2,7 @@
try: try:
import array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(b"123" + array.array('i', [1])) print(b"123" + array.array('i', [1]))

View File

@ -1,9 +1,8 @@
try: try:
import array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(array.array('b', [1, 2]) in b'\x01\x02\x03') print(array.array('b', [1, 2]) in b'\x01\x02\x03')
# CPython gives False here # CPython gives False here

View File

@ -2,9 +2,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# arrays # arrays
print(bytes(array('b', [1, 2]))) print(bytes(array('b', [1, 2])))

View File

@ -3,9 +3,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# arrays # arrays
print(bytes(array('h', [1, 2]))) print(bytes(array('h', [1, 2])))

View File

@ -2,8 +2,7 @@ try:
str.partition str.partition
except AttributeError: except AttributeError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
print(b"asdf".partition(b'g')) print(b"asdf".partition(b'g'))
print(b"asdf".partition(b'a')) print(b"asdf".partition(b'a'))

View File

@ -6,9 +6,8 @@ try:
def __delattr__(self, attr): pass def __delattr__(self, attr): pass
del Test().noexist del Test().noexist
except AttributeError: except AttributeError:
import sys
print('SKIP') print('SKIP')
sys.exit() raise SystemExit
# this class just prints the calls to see if they were executed # this class just prints the calls to see if they were executed
class A(): class A():

View File

@ -21,9 +21,8 @@ m = Main()
try: try:
m.__class__ m.__class__
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
r = m.Forward r = m.Forward
if 'Descriptor' in repr(r.__class__): if 'Descriptor' in repr(r.__class__):

View File

@ -3,9 +3,8 @@ try:
# nothing to test. # nothing to test.
object.__new__ object.__new__
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
class A: class A:
def __new__(cls): def __new__(cls):
print("A.__new__") print("A.__new__")

View File

@ -8,9 +8,8 @@ except ImportError:
try: try:
from ucollections import namedtuple from ucollections import namedtuple
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ]) _DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])

View File

@ -4,9 +4,8 @@ try:
# nothing to test. # nothing to test.
object.__init__ object.__init__
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
class Test(object): class Test(object):
def __init__(self): def __init__(self):

View File

@ -1,9 +1,8 @@
try: try:
reversed reversed
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# argument to fromkeys has no __len__ # argument to fromkeys has no __len__
d = dict.fromkeys(reversed(range(1))) d = dict.fromkeys(reversed(range(1)))

View File

@ -1,9 +1,8 @@
try: try:
enumerate enumerate
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(list(enumerate([]))) print(list(enumerate([])))
print(list(enumerate([1, 2, 3]))) print(list(enumerate([1, 2, 3])))

View File

@ -4,8 +4,7 @@ try:
import uerrno import uerrno
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
# check that constants exist and are integers # check that constants exist and are integers
print(type(uerrno.EIO)) print(type(uerrno.EIO))

View File

@ -1,9 +1,8 @@
try: try:
filter filter
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(list(filter(lambda x: x & 1, range(-3, 4)))) print(list(filter(lambda x: x & 1, range(-3, 4))))
print(list(filter(None, range(-3, 4)))) print(list(filter(None, range(-3, 4))))

View File

@ -4,8 +4,7 @@ try:
frozenset frozenset
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
s = frozenset() s = frozenset()
print(s) print(s)

View File

@ -2,8 +2,7 @@ try:
frozenset frozenset
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
s = frozenset({1, 2, 3, 4}) s = frozenset({1, 2, 3, 4})
try: try:

View File

@ -2,8 +2,7 @@ try:
frozenset frozenset
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
sets = [ sets = [
frozenset(), frozenset({1}), frozenset({1, 2}), frozenset({1, 2, 3}), frozenset({2, 3}), frozenset(), frozenset({1}), frozenset({1, 2}), frozenset({1, 2, 3}), frozenset({2, 3}),

View File

@ -2,8 +2,7 @@ try:
frozenset frozenset
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
s = frozenset({1, 2, 3, 4}) s = frozenset({1, 2, 3, 4})
t = s.copy() t = s.copy()

View File

@ -2,8 +2,7 @@ try:
frozenset frozenset
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
l = [1, 2, 3, 4] l = [1, 2, 3, 4]
s = frozenset(l) s = frozenset(l)

View File

@ -2,8 +2,7 @@ try:
frozenset frozenset
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
# Examples from https://docs.python.org/3/library/stdtypes.html#set # Examples from https://docs.python.org/3/library/stdtypes.html#set
# "Instances of set are compared to instances of frozenset based on their # "Instances of set are compared to instances of frozenset based on their

View File

@ -3,8 +3,7 @@ try:
enumerate enumerate
except: except:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
def test_exc(code, exc): def test_exc(code, exc):
try: try:

View File

@ -4,8 +4,7 @@ try:
import gc import gc
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
print(gc.isenabled()) print(gc.isenabled())
gc.disable() gc.disable()

View File

@ -2,9 +2,8 @@
try: try:
memoryview memoryview
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# test reading from bytes # test reading from bytes
b = b'1234' b = b'1234'

View File

@ -3,9 +3,8 @@ try:
from array import array from array import array
memoryview memoryview
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(list(memoryview(b'\x7f\x80\x81\xff'))) print(list(memoryview(b'\x7f\x80\x81\xff')))
print(list(memoryview(array('b', [0x7f, -0x80])))) print(list(memoryview(array('b', [0x7f, -0x80]))))

View File

@ -2,9 +2,8 @@
try: try:
memoryview memoryview
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
b = bytearray(10) b = bytearray(10)
m = memoryview(b)[1:] m = memoryview(b)[1:]

View File

@ -3,9 +3,8 @@ try:
from array import array from array import array
memoryview memoryview
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(list(memoryview(array('i', [0x7f000000, -0x80000000])))) print(list(memoryview(array('i', [0x7f000000, -0x80000000]))))
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff])))) print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))

View File

@ -4,9 +4,8 @@ try:
except ImportError: except ImportError:
from ucollections import namedtuple from ucollections import namedtuple
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
T = namedtuple("Tup", ["foo", "bar"]) T = namedtuple("Tup", ["foo", "bar"])
# CPython prints fully qualified name, what we don't bother to do so far # CPython prints fully qualified name, what we don't bother to do so far

View File

@ -1,4 +1,3 @@
import sys
class Foo: class Foo:
@ -9,6 +8,6 @@ class Foo:
o = Foo() o = Foo()
if not hasattr(o, "__dict__"): if not hasattr(o, "__dict__"):
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(o.__dict__ == {'a': 1, 'b': 'bar'}) print(o.__dict__ == {'a': 1, 'b': 'bar'})

View File

@ -7,9 +7,8 @@ try:
# nothing to test. # nothing to test.
object.__new__ object.__new__
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
class Foo: class Foo:

View File

@ -2,9 +2,8 @@
try: try:
memoryview memoryview
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
def test_exc(code, exc): def test_exc(code, exc):
try: try:

View File

@ -5,8 +5,7 @@ except ImportError:
from ucollections import OrderedDict from ucollections import OrderedDict
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
d = OrderedDict([(10, 20), ("b", 100), (1, 2)]) d = OrderedDict([(10, 20), ("b", 100), (1, 2)])
print(len(d)) print(len(d))

View File

@ -5,8 +5,7 @@ except ImportError:
from ucollections import OrderedDict from ucollections import OrderedDict
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
x = OrderedDict() x = OrderedDict()
y = OrderedDict() y = OrderedDict()

View File

@ -4,8 +4,7 @@ try:
compile compile
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
# completely empty string # completely empty string
# uPy and CPy differ for this case # uPy and CPy differ for this case

View File

@ -5,9 +5,8 @@
try: try:
set set
except NameError: except NameError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(set) print(set)

View File

@ -8,9 +8,8 @@ class A:
try: try:
t = A()[1:2] t = A()[1:2]
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
A()[1:2:3] A()[1:2:3]

View File

@ -100,9 +100,8 @@ cud2 = Cud()
try: try:
+cud1 +cud1
except TypeError: except TypeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# the following require MICROPY_PY_ALL_SPECIAL_METHODS # the following require MICROPY_PY_ALL_SPECIAL_METHODS
+cud1 +cud1

View File

@ -1,9 +1,8 @@
try: try:
str.center str.center
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print("foo".center(0)) print("foo".center(0))
print("foo".center(1)) print("foo".center(1))

View File

@ -2,8 +2,7 @@ try:
str.partition str.partition
except AttributeError: except AttributeError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
print("asdf".partition('g')) print("asdf".partition('g'))
print("asdf".partition('a')) print("asdf".partition('a'))

View File

@ -2,8 +2,7 @@ try:
str.partition str.partition
except AttributeError: except AttributeError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
print("asdf".rpartition('g')) print("asdf".rpartition('g'))
print("asdf".rpartition('a')) print("asdf".rpartition('a'))

View File

@ -3,9 +3,8 @@
try: try:
str.splitlines str.splitlines
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# test \n as newline # test \n as newline
print("foo\nbar".splitlines()) print("foo\nbar".splitlines())

View File

@ -4,9 +4,8 @@ except:
try: try:
import struct import struct
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(struct.calcsize("<bI")) print(struct.calcsize("<bI"))
print(struct.unpack("<bI", b"\x80\0\0\x01\0")) print(struct.unpack("<bI", b"\x80\0\0\x01\0"))

View File

@ -4,9 +4,8 @@ except:
try: try:
import struct import struct
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
# check maximum pack on 32-bit machine # check maximum pack on 32-bit machine
print(struct.pack("<I", 2**32 - 1)) print(struct.pack("<I", 2**32 - 1))

View File

@ -6,9 +6,8 @@ except:
try: try:
import struct import struct
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(struct.calcsize('0s')) print(struct.calcsize('0s'))
print(struct.unpack('0s', b'')) print(struct.unpack('0s', b''))

View File

@ -6,9 +6,8 @@ except:
try: try:
import struct import struct
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
class A(): class A():
pass pass

View File

@ -8,9 +8,8 @@ class Base:
try: try:
Base.__name__ Base.__name__
except AttributeError: except AttributeError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
class Sub(Base): class Sub(Base):
pass pass

View File

@ -20,7 +20,7 @@ except AttributeError:
print(True) print(True)
try: try:
sys.exit() raise SystemExit
except SystemExit as e: except SystemExit as e:
print("SystemExit", e.args) print("SystemExit", e.args)

View File

@ -3,8 +3,7 @@ try:
set set
except NameError: except NameError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
print(list(zip())) print(list(zip()))
print(list(zip([1], set([2, 3])))) print(list(zip([1], set([2, 3]))))