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:
import array
except ImportError:
import sys
print("SKIP")
sys.exit()
raise SystemExit
a = array.array('B', [1, 2, 3])
print(a, len(a))

View File

@ -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])

View File

@ -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)))

View File

@ -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))))

View File

@ -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'))

View File

@ -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]))

View File

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

View File

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

View File

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

View File

@ -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

View File

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

View File

@ -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))

View File

@ -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:

View File

@ -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))

View File

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

View File

@ -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)

View File

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

View File

@ -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)))

View File

@ -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])))

View File

@ -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])))

View File

@ -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))

View File

@ -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]))

View File

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

View File

@ -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

View File

@ -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])))

View File

@ -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])))

View File

@ -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'))

View File

@ -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():

View File

@ -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__):

View File

@ -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__")

View File

@ -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' ])

View File

@ -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):

View File

@ -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)))

View File

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

View File

@ -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))

View File

@ -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))))

View File

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

View File

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

View File

@ -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}),

View File

@ -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()

View File

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

View File

@ -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

View File

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

View File

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

View File

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

View File

@ -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]))))

View File

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

View File

@ -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]))))

View File

@ -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

View File

@ -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'})

View File

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

View File

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

View File

@ -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))

View File

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

View File

@ -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

View File

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

View File

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

View File

@ -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

View File

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

View File

@ -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'))

View File

@ -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'))

View File

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

View File

@ -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"))

View File

@ -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))

View File

@ -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''))

View File

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

View File

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

View File

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

View File

@ -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]))))