tests/basic/[a-f]*: Make skippable.
For small ports which don't have all features enabled.
This commit is contained in:
parent
453f98914e
commit
83623b2fde
@ -1,5 +1,10 @@
|
||||
# test MicroPython-specific features of array.array
|
||||
import array
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
# arrays of objects
|
||||
a = array.array('O')
|
||||
|
@ -4,6 +4,15 @@
|
||||
import sys
|
||||
t = sys.implementation
|
||||
|
||||
# It can be just a normal tuple on small ports
|
||||
try:
|
||||
t.name
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
|
||||
# test printing of attrtuple
|
||||
print(str(t).find("version=") > 0)
|
||||
|
||||
|
@ -1,4 +1,10 @@
|
||||
# test builtin delattr
|
||||
try:
|
||||
delattr
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
class A: pass
|
||||
a = A()
|
||||
|
@ -1,4 +1,11 @@
|
||||
# test builtin min and max functions
|
||||
try:
|
||||
min
|
||||
max
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
print(min(0,1))
|
||||
print(min(1,0))
|
||||
|
@ -3,7 +3,13 @@
|
||||
import builtins
|
||||
|
||||
# override generic builtin
|
||||
builtins.abs = lambda x: x + 1
|
||||
try:
|
||||
builtins.abs = lambda x: x + 1
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
print(abs(1))
|
||||
|
||||
# __build_class__ is handled in a special way
|
||||
|
@ -34,11 +34,6 @@ print(range(1, 4)[1:])
|
||||
print(range(1, 4)[:-1])
|
||||
print(range(7, -2, -4)[:])
|
||||
|
||||
# attrs
|
||||
print(range(1, 2, 3).start)
|
||||
print(range(1, 2, 3).stop)
|
||||
print(range(1, 2, 3).step)
|
||||
|
||||
# bad unary op
|
||||
try:
|
||||
-range(1)
|
||||
@ -50,9 +45,3 @@ try:
|
||||
range(1)[0] = 1
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
# bad attr (can't store)
|
||||
try:
|
||||
range(4).start = 0
|
||||
except AttributeError:
|
||||
print('AttributeError')
|
||||
|
19
tests/basics/builtin_range_attrs.py
Normal file
19
tests/basics/builtin_range_attrs.py
Normal file
@ -0,0 +1,19 @@
|
||||
# test attributes of builtin range type
|
||||
|
||||
try:
|
||||
range(0).start
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
# attrs
|
||||
print(range(1, 2, 3).start)
|
||||
print(range(1, 2, 3).stop)
|
||||
print(range(1, 2, 3).step)
|
||||
|
||||
# bad attr (can't store)
|
||||
try:
|
||||
range(4).start = 0
|
||||
except AttributeError:
|
||||
print('AttributeError')
|
@ -1,4 +1,10 @@
|
||||
# test the builtin reverse() function
|
||||
try:
|
||||
reversed
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
# list
|
||||
print(list(reversed([])))
|
||||
|
@ -18,6 +18,13 @@ class Main:
|
||||
Forward = Descriptor()
|
||||
|
||||
m = Main()
|
||||
try:
|
||||
m.__class__
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
r = m.Forward
|
||||
if 'Descriptor' in repr(r.__class__):
|
||||
print('SKIP')
|
||||
|
@ -1,3 +1,11 @@
|
||||
try:
|
||||
# If we don't expose object.__new__ (small ports), there's
|
||||
# nothing to test.
|
||||
object.__new__
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
class A:
|
||||
def __new__(cls):
|
||||
print("A.__new__")
|
||||
|
@ -5,7 +5,12 @@
|
||||
try:
|
||||
from collections import namedtuple
|
||||
except ImportError:
|
||||
from ucollections import namedtuple
|
||||
try:
|
||||
from ucollections import namedtuple
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])
|
||||
|
||||
|
@ -1,4 +1,12 @@
|
||||
# Calling object.__init__() via super().__init__
|
||||
try:
|
||||
# If we don't expose object.__init__ (small ports), there's
|
||||
# nothing to test.
|
||||
object.__init__
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
class Test(object):
|
||||
def __init__(self):
|
||||
|
@ -9,5 +9,6 @@ l.sort()
|
||||
print(l)
|
||||
|
||||
# argument to fromkeys has no __len__
|
||||
d = dict.fromkeys(reversed(range(1)))
|
||||
#d = dict.fromkeys(reversed(range(1)))
|
||||
d = dict.fromkeys((x for x in range(1)))
|
||||
print(d)
|
||||
|
@ -1,3 +1,10 @@
|
||||
try:
|
||||
enumerate
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
print(list(enumerate([])))
|
||||
print(list(enumerate([1, 2, 3])))
|
||||
print(list(enumerate([1, 2, 3], 5)))
|
||||
|
@ -1,2 +1,9 @@
|
||||
try:
|
||||
filter
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
print(list(filter(lambda x: x & 1, range(-3, 4))))
|
||||
print(list(filter(None, range(-3, 4))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user