tests/basics: Convert "sys.exit()" to "raise SystemExit".
This commit is contained in:
parent
0161939ed1
commit
a2803b74f4
|
@ -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))
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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]))
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# arrays of objects
|
||||
a = array.array('O')
|
||||
|
|
|
@ -8,9 +8,8 @@ t = sys.implementation
|
|||
try:
|
||||
t.name
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
|
||||
# test printing of attrtuple
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
delattr
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
class A: pass
|
||||
a = A()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,9 +3,8 @@ try:
|
|||
min
|
||||
max
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(min(0,1))
|
||||
print(min(1,0))
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
property
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# create a property object explicitly
|
||||
property()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
reversed
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# list
|
||||
print(list(reversed([])))
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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])))
|
||||
|
|
|
@ -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])))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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]))
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(b"123" + array.array('i', [1]))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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])))
|
||||
|
|
|
@ -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])))
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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__):
|
||||
|
|
|
@ -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__")
|
||||
|
|
|
@ -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' ])
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
try:
|
||||
enumerate
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(list(enumerate([])))
|
||||
print(list(enumerate([1, 2, 3])))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -4,8 +4,7 @@ try:
|
|||
frozenset
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
s = frozenset()
|
||||
print(s)
|
||||
|
|
|
@ -2,8 +2,7 @@ try:
|
|||
frozenset
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
s = frozenset({1, 2, 3, 4})
|
||||
try:
|
||||
|
|
|
@ -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}),
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -2,8 +2,7 @@ try:
|
|||
frozenset
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
l = [1, 2, 3, 4]
|
||||
s = frozenset(l)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,8 +3,7 @@ try:
|
|||
enumerate
|
||||
except:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
def test_exc(code, exc):
|
||||
try:
|
||||
|
|
|
@ -4,8 +4,7 @@ try:
|
|||
import gc
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(gc.isenabled())
|
||||
gc.disable()
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
memoryview
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# test reading from bytes
|
||||
b = b'1234'
|
||||
|
|
|
@ -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]))))
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
memoryview
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
b = bytearray(10)
|
||||
m = memoryview(b)[1:]
|
||||
|
|
|
@ -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]))))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'})
|
||||
|
|
|
@ -7,9 +7,8 @@ try:
|
|||
# nothing to test.
|
||||
object.__new__
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
class Foo:
|
||||
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
memoryview
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
def test_exc(code, exc):
|
||||
try:
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -5,8 +5,7 @@ except ImportError:
|
|||
from ucollections import OrderedDict
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
x = OrderedDict()
|
||||
y = OrderedDict()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
try:
|
||||
set
|
||||
except NameError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(set)
|
||||
|
||||
|
|
|
@ -8,9 +8,8 @@ class A:
|
|||
try:
|
||||
t = A()[1:2]
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
|
||||
A()[1:2:3]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
try:
|
||||
str.center
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print("foo".center(0))
|
||||
print("foo".center(1))
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
try:
|
||||
str.splitlines
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# test \n as newline
|
||||
print("foo\nbar".splitlines())
|
||||
|
|
|
@ -4,9 +4,8 @@ except:
|
|||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(struct.calcsize("<bI"))
|
||||
print(struct.unpack("<bI", b"\x80\0\0\x01\0"))
|
||||
|
|
|
@ -4,9 +4,8 @@ except:
|
|||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# check maximum pack on 32-bit machine
|
||||
print(struct.pack("<I", 2**32 - 1))
|
||||
|
|
|
@ -6,9 +6,8 @@ except:
|
|||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(struct.calcsize('0s'))
|
||||
print(struct.unpack('0s', b''))
|
||||
|
|
|
@ -6,9 +6,8 @@ except:
|
|||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
class A():
|
||||
pass
|
||||
|
|
|
@ -8,9 +8,8 @@ class Base:
|
|||
try:
|
||||
Base.__name__
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
class Sub(Base):
|
||||
pass
|
||||
|
|
|
@ -20,7 +20,7 @@ except AttributeError:
|
|||
print(True)
|
||||
|
||||
try:
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
except SystemExit as e:
|
||||
print("SystemExit", e.args)
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ try:
|
|||
set
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(list(zip()))
|
||||
print(list(zip([1], set([2, 3]))))
|
||||
|
|
Loading…
Reference in New Issue