tests/extmod: Make tests skippable.

This commit is contained in:
Paul Sokolovsky 2017-02-15 01:56:22 +03:00
parent 7bb146350e
commit f2d732f459
41 changed files with 254 additions and 62 deletions

View File

@ -5,7 +5,8 @@ try:
import umachine as machine import umachine as machine
except ImportError: except ImportError:
import machine import machine
except ImportError: machine.mem8
except:
print("SKIP") print("SKIP")
import sys import sys
sys.exit() sys.exit()

View File

@ -1,7 +1,12 @@
try: try:
import ubinascii as binascii try:
import ubinascii as binascii
except ImportError:
import binascii
except ImportError: except ImportError:
import binascii import sys
print("SKIP")
sys.exit()
print(binascii.a2b_base64(b'')) print(binascii.a2b_base64(b''))
print(binascii.a2b_base64(b'Zg==')) print(binascii.a2b_base64(b'Zg=='))

View File

@ -1,7 +1,12 @@
try: try:
import ubinascii as binascii try:
import ubinascii as binascii
except ImportError:
import binascii
except ImportError: except ImportError:
import binascii import sys
print("SKIP")
sys.exit()
print(binascii.b2a_base64(b'')) print(binascii.b2a_base64(b''))
print(binascii.b2a_base64(b'f')) print(binascii.b2a_base64(b'f'))

View File

@ -1,7 +1,13 @@
try: try:
import ubinascii as binascii try:
import ubinascii as binascii
except ImportError:
import binascii
except ImportError: except ImportError:
import binascii import sys
print("SKIP")
sys.exit()
try: try:
binascii.crc32 binascii.crc32
except AttributeError: except AttributeError:

View File

@ -1,7 +1,12 @@
try: try:
import ubinascii as binascii try:
import ubinascii as binascii
except ImportError:
import binascii
except ImportError: except ImportError:
import binascii import sys
print("SKIP")
sys.exit()
print(binascii.hexlify(b'\x00\x01\x02\x03\x04\x05\x06\x07')) print(binascii.hexlify(b'\x00\x01\x02\x03\x04\x05\x06\x07'))
print(binascii.hexlify(b'\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')) print(binascii.hexlify(b'\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'))

View File

@ -1,7 +1,12 @@
try: try:
import ubinascii as binascii try:
import ubinascii as binascii
except ImportError:
import binascii
except ImportError: except ImportError:
import binascii import sys
print("SKIP")
sys.exit()
# two arguments supported in uPy but not CPython # two arguments supported in uPy but not CPython
a = binascii.hexlify(b'123', ':') a = binascii.hexlify(b'123', ':')

View File

@ -1,7 +1,12 @@
try: try:
import ubinascii as binascii try:
import ubinascii as binascii
except ImportError:
import binascii
except ImportError: except ImportError:
import binascii import sys
print("SKIP")
sys.exit()
print(binascii.unhexlify(b'0001020304050607')) print(binascii.unhexlify(b'0001020304050607'))
print(binascii.unhexlify(b'08090a0b0c0d0e0f')) print(binascii.unhexlify(b'08090a0b0c0d0e0f'))

View File

@ -1,4 +1,9 @@
import uctypes try:
import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
desc = { desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2 # arr is array at offset 0, of UINT8 elements, array size is 2

View File

@ -1,5 +1,9 @@
import sys import sys
import uctypes try:
import uctypes
except ImportError:
print("SKIP")
sys.exit()
if sys.byteorder != "little": if sys.byteorder != "little":
print("SKIP") print("SKIP")

View File

@ -1,4 +1,9 @@
import uctypes try:
import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
desc = { desc = {
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2), "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),

View File

@ -1,4 +1,9 @@
import uctypes try:
import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
desc = { desc = {
"s0": uctypes.UINT16 | 0, "s0": uctypes.UINT16 | 0,

View File

@ -1,4 +1,9 @@
import uctypes try:
import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
desc = { desc = {
"f32": uctypes.FLOAT32 | 0, "f32": uctypes.FLOAT32 | 0,

View File

@ -1,4 +1,9 @@
import uctypes try:
import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
desc = { desc = {
"f32": uctypes.FLOAT32 | 0, "f32": uctypes.FLOAT32 | 0,

View File

@ -2,7 +2,11 @@
# Codepaths for packed vs native structures are different. This test only works # Codepaths for packed vs native structures are different. This test only works
# on little-endian machine (no matter if 32 or 64 bit). # on little-endian machine (no matter if 32 or 64 bit).
import sys import sys
import uctypes try:
import uctypes
except ImportError:
print("SKIP")
sys.exit()
if sys.byteorder != "little": if sys.byteorder != "little":
print("SKIP") print("SKIP")

View File

@ -1,6 +1,10 @@
# test printing of uctypes objects # test printing of uctypes objects
try:
import uctypes import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
# we use an address of "0" because we just want to print something deterministic # we use an address of "0" because we just want to print something deterministic
# and don't actually need to set/get any values in the struct # and don't actually need to set/get any values in the struct

View File

@ -1,5 +1,9 @@
import sys import sys
import uctypes try:
import uctypes
except ImportError:
print("SKIP")
sys.exit()
if sys.byteorder != "little": if sys.byteorder != "little":
print("SKIP") print("SKIP")

View File

@ -1,5 +1,9 @@
import sys import sys
import uctypes try:
import uctypes
except ImportError:
print("SKIP")
sys.exit()
if sys.byteorder != "little": if sys.byteorder != "little":
print("SKIP") print("SKIP")

View File

@ -1,4 +1,9 @@
import uctypes try:
import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
desc = { desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2 # arr is array at offset 0, of UINT8 elements, array size is 2

View File

@ -1,4 +1,9 @@
import uctypes try:
import uctypes
except ImportError:
import sys
print("SKIP")
sys.exit()
S1 = {} S1 = {}
assert uctypes.sizeof(S1) == 0 assert uctypes.sizeof(S1) == 0

View File

@ -1,7 +1,12 @@
try: try:
import uheapq as heapq import uheapq as heapq
except: except:
import heapq try:
import heapq
except ImportError:
import sys
print("SKIP")
sys.exit()
try: try:
heapq.heappop([]) heapq.heappop([])

View File

@ -1,7 +1,12 @@
try: try:
import ujson as json import ujson as json
except ImportError: except ImportError:
import json try:
import json
except ImportError:
import sys
print("SKIP")
sys.exit()
print(json.dumps(False)) print(json.dumps(False))
print(json.dumps(True)) print(json.dumps(True))

View File

@ -1,5 +1,10 @@
# test uPy ujson behaviour that's not valid in CPy # test uPy ujson behaviour that's not valid in CPy
import ujson try:
import ujson
except ImportError:
import sys
print("SKIP")
sys.exit()
print(ujson.dumps(b'1234')) print(ujson.dumps(b'1234'))

View File

@ -1,6 +1,11 @@
try: try:
import ujson as json import ujson as json
except ImportError: except ImportError:
import json try:
import json
except ImportError:
import sys
print("SKIP")
sys.exit()
print(json.dumps(1.2)) print(json.dumps(1.2))

View File

@ -2,8 +2,13 @@ try:
from uio import StringIO from uio import StringIO
import ujson as json import ujson as json
except: except:
from io import StringIO try:
import json from io import StringIO
import json
except ImportError:
import sys
print("SKIP")
sys.exit()
print(json.load(StringIO('null'))) print(json.load(StringIO('null')))
print(json.load(StringIO('"abc\\u0064e"'))) print(json.load(StringIO('"abc\\u0064e"')))

View File

@ -1,7 +1,12 @@
try: try:
import ujson as json import ujson as json
except: except ImportError:
import json try:
import json
except ImportError:
import sys
print("SKIP")
sys.exit()
def my_print(o): def my_print(o):
if isinstance(o, dict): if isinstance(o, dict):

View File

@ -1,7 +1,12 @@
try: try:
import ujson as json import ujson as json
except: except ImportError:
import json try:
import json
except ImportError:
import sys
print("SKIP")
sys.exit()
def my_print(o): def my_print(o):
print('%.3f' % o) print('%.3f' % o)

View File

@ -1,7 +1,12 @@
try: try:
import urandom as random import urandom as random
except ImportError: except ImportError:
import random try:
import random
except ImportError:
import sys
print("SKIP")
sys.exit()
# check getrandbits returns a value within the bit range # check getrandbits returns a value within the bit range
for b in (1, 2, 3, 4, 16, 32): for b in (1, 2, 3, 4, 16, 32):

View File

@ -1,7 +1,12 @@
try: try:
import urandom as random import urandom as random
except ImportError: except ImportError:
import random try:
import random
except ImportError:
import sys
print("SKIP")
sys.exit()
try: try:
random.randint random.randint

View File

@ -1,7 +1,12 @@
try: try:
import ure as re import ure as re
except ImportError: except ImportError:
import re try:
import re
except ImportError:
import sys
print("SKIP")
sys.exit()
r = re.compile(".+") r = re.compile(".+")
m = r.match("abc") m = r.match("abc")

View File

@ -1,3 +1,9 @@
# test printing debugging info when compiling # test printing debugging info when compiling
import ure try:
import ure
except ImportError:
import sys
print("SKIP")
sys.exit()
ure.compile('^a|b[0-9]\w$', ure.DEBUG) ure.compile('^a|b[0-9]\w$', ure.DEBUG)

View File

@ -2,8 +2,13 @@
try: try:
import ure as re import ure as re
except: except ImportError:
import re try:
import re
except ImportError:
import sys
print("SKIP")
sys.exit()
def test_re(r): def test_re(r):
try: try:

View File

@ -2,8 +2,13 @@
try: try:
import ure as re import ure as re
except: except ImportError:
import re try:
import re
except ImportError:
import sys
print("SKIP")
sys.exit()
def print_groups(match): def print_groups(match):
print('----') print('----')

View File

@ -2,8 +2,13 @@
try: try:
import ure as re import ure as re
except: except ImportError:
import re try:
import re
except ImportError:
import sys
print("SKIP")
sys.exit()
def print_groups(match): def print_groups(match):
print('----') print('----')

View File

@ -1,7 +1,12 @@
try: try:
import ure as re import ure as re
except ImportError: except ImportError:
import re try:
import re
except ImportError:
import sys
print("SKIP")
sys.exit()
r = re.compile(" ") r = re.compile(" ")
s = r.split("a b c foobar") s = r.split("a b c foobar")

View File

@ -4,7 +4,12 @@
# behaviour will change in a future version. MicroPython just stops # behaviour will change in a future version. MicroPython just stops
# splitting as soon as an empty match is found. # splitting as soon as an empty match is found.
import ure as re try:
import ure as re
except ImportError:
import sys
print("SKIP")
sys.exit()
r = re.compile(" *") r = re.compile(" *")
s = r.split("a b c foobar") s = r.split("a b c foobar")

View File

@ -1,4 +1,9 @@
import ure as re try:
import ure as re
except ImportError:
import sys
print("SKIP")
sys.exit()
r = re.compile('( )') r = re.compile('( )')
try: try:

View File

@ -1,8 +1,10 @@
try: try:
import zlib
except ImportError:
import uzlib as zlib import uzlib as zlib
import uio as io import uio as io
except ImportError:
import sys
print("SKIP")
sys.exit()
# Raw DEFLATE bitstream # Raw DEFLATE bitstream

View File

@ -1,8 +1,10 @@
try: try:
import zlib
except ImportError:
import uzlib as zlib import uzlib as zlib
import uio as io import uio as io
except ImportError:
import sys
print("SKIP")
sys.exit()
# gzip bitstream # gzip bitstream

View File

@ -1,7 +1,12 @@
try: try:
import zlib import zlib
except ImportError: except ImportError:
import uzlib as zlib try:
import uzlib as zlib
except ImportError:
import sys
print("SKIP")
sys.exit()
PATTERNS = [ PATTERNS = [
# Packed results produced by CPy's zlib.compress() # Packed results produced by CPy's zlib.compress()

View File

@ -1,9 +1,14 @@
import sys import sys
import uerrno
try: try:
import uos_vfs as uos import uerrno
try:
import uos_vfs as uos
except ImportError:
import uos
except ImportError: except ImportError:
import uos print("SKIP")
sys.exit()
try: try:
uos.VfsFat uos.VfsFat
except AttributeError: except AttributeError:

View File

@ -1,9 +1,14 @@
import sys import sys
import uerrno
try: try:
import uos_vfs as uos import uerrno
try:
import uos_vfs as uos
except ImportError:
import uos
except ImportError: except ImportError:
import uos print("SKIP")
sys.exit()
try: try:
uos.VfsFat uos.VfsFat
except AttributeError: except AttributeError: