Skip to content

Commit c9fa667

Browse files
committed
tests: Add tests for non-compliant behaviour.
These tests are intended to improve coverage and provide a record of behaviour that's either not implemented or non-compliant to CPython.
1 parent c2ec2ad commit c9fa667

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

tests/misc/non_compliant.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# tests for things that are not implemented, or have non-compliant behaviour
2+
3+
import array
4+
5+
# array deletion not implemented
6+
try:
7+
a = array.array('b', (1, 2, 3))
8+
del a[1]
9+
except TypeError:
10+
print('TypeError')
11+
12+
# slice with step!=1 not implemented
13+
try:
14+
a = array.array('b', (1, 2, 3))
15+
print(a[3:2:2])
16+
except NotImplementedError:
17+
print('NotImplementedError')
18+
19+
# should raise type error
20+
try:
21+
print(set('12') >= '1')
22+
except TypeError:
23+
print('TypeError')
24+
25+
# should raise type error
26+
try:
27+
print(set('12') <= '123')
28+
except TypeError:
29+
print('TypeError')
30+
31+
# uPy raises TypeError, shold be ValueError
32+
try:
33+
'%c' % b'\x01\x02'
34+
except (TypeError, ValueError):
35+
print('TypeError, ValueError')
36+
37+
# attributes/subscr not implemented
38+
try:
39+
print('{a[0]}'.format(a=[1, 2]))
40+
except NotImplementedError:
41+
print('NotImplementedError')

tests/misc/non_compliant.py.exp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
TypeError
2+
NotImplementedError
3+
True
4+
True
5+
TypeError
6+
NotImplementedError

0 commit comments

Comments
 (0)