Skip to content

Commit 846101d

Browse files
committed
Python: Extend isSequence/isMapping test with custom classes
1 parent 65ce6d2 commit 846101d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

python/ql/test/library-tests/PointsTo/class_properties/ClassValues.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| mapping | class MySequenceImpl |
12
| neither sequence nor mapping | builtin-class set |
23
| sequence | builtin-class bytes |
34
| sequence | builtin-class collections.OrderedDict |
@@ -6,4 +7,7 @@
67
| sequence | builtin-class list |
78
| sequence | builtin-class str |
89
| sequence | builtin-class tuple |
10+
| sequence | class MyDictSubclass |
11+
| sequence | class MyMappingABC |
12+
| sequence | class MySequenceABC |
913
| sequence | class OrderedDict |

python/ql/test/library-tests/PointsTo/class_properties/test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,35 @@
44
def test(*args):
55
pass
66

7+
class MySequenceABC(collections.abc.Sequence):
8+
pass
9+
10+
class MyMappingABC(collections.abc.Mapping):
11+
pass
12+
13+
class MySequenceImpl(object):
14+
def __getitem__(self, key):
15+
pass
16+
17+
def __len__(self):
18+
pass
19+
20+
class MyDictSubclass(dict):
21+
pass
22+
723
test(
824
list,
925
tuple,
1026
str,
1127
bytes,
28+
MySequenceABC,
29+
MySequenceImpl,
1230
set,
1331
dict,
1432
OrderedDict,
1533
defaultdict,
34+
MyMappingABC,
35+
MyDictSubclass,
1636
)
1737

1838
for seq_cls in (list, tuple, str, bytes):

0 commit comments

Comments
 (0)