Skip to content

Commit f980c70

Browse files
committed
tests/basic/: Make various tests skippable.
To run the testsuite on small ports.
1 parent b737c9c commit f980c70

14 files changed

Lines changed: 222 additions & 49 deletions

tests/basics/iter_of_iter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
print(list(i))
55
i = iter(iter({1:2, 3:4, 5:6}))
66
print(sorted(i))
7-
i = iter(iter({1, 2, 3}))
8-
print(sorted(i))
7+
# set, see set_iter_of_iter.py

tests/basics/map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
print(list(map(lambda x: x & 1, range(-3, 4))))
22
print(list(map(abs, range(-3, 4))))
3-
print(list(map(set, [[i] for i in range(-3, 4)])))
3+
print(list(map(tuple, [[i] for i in range(-3, 4)])))
44
print(list(map(pow, range(4), range(4))))

tests/basics/memoryview1.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# test memoryview
2+
try:
3+
memoryview
4+
except:
5+
import sys
6+
print("SKIP")
7+
sys.exit()
28

39
# test reading from bytes
410
b = b'1234'

tests/basics/memoryview2.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# test memoryview accessing maximum values for signed/unsigned elements
2-
3-
from array import array
2+
try:
3+
from array import array
4+
memoryview
5+
except:
6+
import sys
7+
print("SKIP")
8+
sys.exit()
49

510
print(list(memoryview(b'\x7f\x80\x81\xff')))
611
print(list(memoryview(array('b', [0x7f, -0x80]))))

tests/basics/memoryview_gc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# test memoryview retains pointer to original object/buffer
2+
try:
3+
memoryview
4+
except:
5+
import sys
6+
print("SKIP")
7+
sys.exit()
28

39
b = bytearray(10)
410
m = memoryview(b)[1:]

tests/basics/namedtuple1.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
try:
2-
from collections import namedtuple
2+
try:
3+
from collections import namedtuple
4+
except ImportError:
5+
from ucollections import namedtuple
36
except ImportError:
4-
from ucollections import namedtuple
7+
import sys
8+
print("SKIP")
9+
sys.exit()
510

611
T = namedtuple("Tup", ["foo", "bar"])
712
# CPython prints fully qualified name, what we don't bother to do so far

tests/basics/object_new.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
# (non-initialized) instance of class.
33
# See e.g. http://infohost.nmt.edu/tcc/help/pubs/python/web/new-new-method.html
44
# TODO: Find reference in CPython docs
5+
try:
6+
# If we don't expose object.__new__ (small ports), there's
7+
# nothing to test.
8+
object.__new__
9+
except AttributeError:
10+
import sys
11+
print("SKIP")
12+
sys.exit()
513

614
class Foo:
715

tests/basics/op_error.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def test_exc(code, exc):
2020
test_exc("1 * {}", TypeError)
2121
test_exc("1 in 1", TypeError)
2222
test_exc("bytearray() // 2", TypeError)
23-
test_exc("m = memoryview(bytearray())\nm += bytearray()", TypeError)
2423

2524
# object with buffer protocol needed on rhs
2625
test_exc("bytearray(1) + 1", TypeError)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# test errors from bad operations (unary, binary, etc)
2+
try:
3+
memoryview
4+
except:
5+
import sys
6+
print("SKIP")
7+
sys.exit()
8+
9+
def test_exc(code, exc):
10+
try:
11+
exec(code)
12+
print("no exception")
13+
except exc:
14+
print("right exception")
15+
except:
16+
print("wrong exception")
17+
18+
# unsupported binary operators
19+
test_exc("m = memoryview(bytearray())\nm += bytearray()", TypeError)

tests/basics/set_iter_of_iter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
i = iter(iter({1, 2, 3}))
2+
print(sorted(i))

0 commit comments

Comments
 (0)