diff --git a/tests/basics/array_micropython.py b/tests/basics/array_micropython.py index 8e904bdfea..0c1df0923b 100644 --- a/tests/basics/array_micropython.py +++ b/tests/basics/array_micropython.py @@ -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') diff --git a/tests/basics/attrtuple1.py b/tests/basics/attrtuple1.py index c4daaaf257..597bfc2a32 100644 --- a/tests/basics/attrtuple1.py +++ b/tests/basics/attrtuple1.py @@ -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) diff --git a/tests/basics/builtin_delattr.py b/tests/basics/builtin_delattr.py index 3743df227c..9b38837e44 100644 --- a/tests/basics/builtin_delattr.py +++ b/tests/basics/builtin_delattr.py @@ -1,4 +1,10 @@ # test builtin delattr +try: + delattr +except: + import sys + print("SKIP") + sys.exit() class A: pass a = A() diff --git a/tests/basics/builtin_minmax.py b/tests/basics/builtin_minmax.py index d395d4421b..a925b3fe92 100644 --- a/tests/basics/builtin_minmax.py +++ b/tests/basics/builtin_minmax.py @@ -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)) diff --git a/tests/basics/builtin_override.py b/tests/basics/builtin_override.py index e245985ad9..f3632e59a7 100644 --- a/tests/basics/builtin_override.py +++ b/tests/basics/builtin_override.py @@ -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 diff --git a/tests/basics/builtin_range.py b/tests/basics/builtin_range.py index 59fc0344a4..7c3e5beeff 100644 --- a/tests/basics/builtin_range.py +++ b/tests/basics/builtin_range.py @@ -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') diff --git a/tests/basics/builtin_range_attrs.py b/tests/basics/builtin_range_attrs.py new file mode 100644 index 0000000000..9327c802a5 --- /dev/null +++ b/tests/basics/builtin_range_attrs.py @@ -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') diff --git a/tests/basics/builtin_reversed.py b/tests/basics/builtin_reversed.py index f129a4f5d5..59e9c78219 100644 --- a/tests/basics/builtin_reversed.py +++ b/tests/basics/builtin_reversed.py @@ -1,4 +1,10 @@ # test the builtin reverse() function +try: + reversed +except: + import sys + print("SKIP") + sys.exit() # list print(list(reversed([]))) diff --git a/tests/basics/class_descriptor.py b/tests/basics/class_descriptor.py index 25b373e47e..7f295f071e 100644 --- a/tests/basics/class_descriptor.py +++ b/tests/basics/class_descriptor.py @@ -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') diff --git a/tests/basics/class_new.py b/tests/basics/class_new.py index a6a34c5811..0198456b24 100644 --- a/tests/basics/class_new.py +++ b/tests/basics/class_new.py @@ -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__") diff --git a/tests/basics/class_store_class.py b/tests/basics/class_store_class.py index 10b94d3c6a..00a2915869 100644 --- a/tests/basics/class_store_class.py +++ b/tests/basics/class_store_class.py @@ -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' ]) diff --git a/tests/basics/class_super_object.py b/tests/basics/class_super_object.py index 21b97328ea..a841d34abb 100644 --- a/tests/basics/class_super_object.py +++ b/tests/basics/class_super_object.py @@ -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): diff --git a/tests/basics/dict_fromkeys.py b/tests/basics/dict_fromkeys.py index bfad347c89..796f657d7e 100644 --- a/tests/basics/dict_fromkeys.py +++ b/tests/basics/dict_fromkeys.py @@ -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) diff --git a/tests/basics/enumerate.py b/tests/basics/enumerate.py index 00595cb0f6..3cc1350a0f 100644 --- a/tests/basics/enumerate.py +++ b/tests/basics/enumerate.py @@ -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))) diff --git a/tests/basics/filter.py b/tests/basics/filter.py index 5883e3d00b..d0b36733c3 100644 --- a/tests/basics/filter.py +++ b/tests/basics/filter.py @@ -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))))