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
|
# test MicroPython-specific features of array.array
|
||||||
|
try:
|
||||||
import array
|
import array
|
||||||
|
except ImportError:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# arrays of objects
|
# arrays of objects
|
||||||
a = array.array('O')
|
a = array.array('O')
|
||||||
|
@ -4,6 +4,15 @@
|
|||||||
import sys
|
import sys
|
||||||
t = sys.implementation
|
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
|
# test printing of attrtuple
|
||||||
print(str(t).find("version=") > 0)
|
print(str(t).find("version=") > 0)
|
||||||
|
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
# test builtin delattr
|
# test builtin delattr
|
||||||
|
try:
|
||||||
|
delattr
|
||||||
|
except:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
class A: pass
|
class A: pass
|
||||||
a = A()
|
a = A()
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# test builtin min and max functions
|
# test builtin min and max functions
|
||||||
|
try:
|
||||||
|
min
|
||||||
|
max
|
||||||
|
except:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
print(min(0,1))
|
print(min(0,1))
|
||||||
print(min(1,0))
|
print(min(1,0))
|
||||||
|
@ -3,7 +3,13 @@
|
|||||||
import builtins
|
import builtins
|
||||||
|
|
||||||
# override generic builtin
|
# override generic builtin
|
||||||
|
try:
|
||||||
builtins.abs = lambda x: x + 1
|
builtins.abs = lambda x: x + 1
|
||||||
|
except AttributeError:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
print(abs(1))
|
print(abs(1))
|
||||||
|
|
||||||
# __build_class__ is handled in a special way
|
# __build_class__ is handled in a special way
|
||||||
|
@ -34,11 +34,6 @@ print(range(1, 4)[1:])
|
|||||||
print(range(1, 4)[:-1])
|
print(range(1, 4)[:-1])
|
||||||
print(range(7, -2, -4)[:])
|
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
|
# bad unary op
|
||||||
try:
|
try:
|
||||||
-range(1)
|
-range(1)
|
||||||
@ -50,9 +45,3 @@ try:
|
|||||||
range(1)[0] = 1
|
range(1)[0] = 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("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
|
# test the builtin reverse() function
|
||||||
|
try:
|
||||||
|
reversed
|
||||||
|
except:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# list
|
# list
|
||||||
print(list(reversed([])))
|
print(list(reversed([])))
|
||||||
|
@ -18,6 +18,13 @@ class Main:
|
|||||||
Forward = Descriptor()
|
Forward = Descriptor()
|
||||||
|
|
||||||
m = Main()
|
m = Main()
|
||||||
|
try:
|
||||||
|
m.__class__
|
||||||
|
except AttributeError:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
r = m.Forward
|
r = m.Forward
|
||||||
if 'Descriptor' in repr(r.__class__):
|
if 'Descriptor' in repr(r.__class__):
|
||||||
print('SKIP')
|
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:
|
class A:
|
||||||
def __new__(cls):
|
def __new__(cls):
|
||||||
print("A.__new__")
|
print("A.__new__")
|
||||||
|
@ -5,7 +5,12 @@
|
|||||||
try:
|
try:
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
from ucollections import namedtuple
|
from ucollections import namedtuple
|
||||||
|
except ImportError:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])
|
_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])
|
||||||
|
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
# Calling object.__init__() via super().__init__
|
# 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):
|
class Test(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -9,5 +9,6 @@ l.sort()
|
|||||||
print(l)
|
print(l)
|
||||||
|
|
||||||
# argument to fromkeys has no __len__
|
# 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)
|
print(d)
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
try:
|
||||||
|
enumerate
|
||||||
|
except:
|
||||||
|
import sys
|
||||||
|
print("SKIP")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
print(list(enumerate([])))
|
print(list(enumerate([])))
|
||||||
print(list(enumerate([1, 2, 3])))
|
print(list(enumerate([1, 2, 3])))
|
||||||
print(list(enumerate([1, 2, 3], 5)))
|
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(lambda x: x & 1, range(-3, 4))))
|
||||||
print(list(filter(None, range(-3, 4))))
|
print(list(filter(None, range(-3, 4))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user