-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtest_c_subclass.py
149 lines (134 loc) · 4.45 KB
/
test_c_subclass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import datetime
import sys
import zoneinfo
import pytest
from cPyExtPatt.SubClass import sublist
def test_sublist_dir():
result = dir(sublist)
assert result == ['SubList',
'__doc__',
'__file__',
'__loader__',
'__name__',
'__package__',
'__spec__']
@pytest.mark.skipif(not (sys.version_info.minor <= 10), reason='Python 3.9, 3.10')
def test_sublist_sublist_dir_pre_311():
sublist_object = sublist.SubList()
result = dir(sublist_object)
assert result == ['__add__',
'__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__gt__',
'__hash__',
'__iadd__',
'__imul__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__reversed__',
'__rmul__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'append',
'appends',
'clear',
'copy',
'count',
'extend',
'increment',
'index',
'insert',
'pop',
'remove',
'reverse',
'sort',
'state']
@pytest.mark.skipif(not (sys.version_info.minor > 10), reason='Python 3.11+')
def test_sublist_sublist_dir_post_310():
sublist_object = sublist.SubList()
result = dir(sublist_object)
assert result == ['__add__',
'__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getstate__',
'__gt__',
'__hash__',
'__iadd__',
'__imul__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__reversed__',
'__rmul__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'append',
'appends',
'clear',
'copy',
'count',
'extend',
'increment',
'index',
'insert',
'pop',
'remove',
'reverse',
'sort',
'state']
def test_sublist_sublist_append():
obj = sublist.SubList()
assert obj.appends == 0
obj.append(42)
assert obj.appends == 1
assert obj == [42, ]
def test_sublist_sublist_state():
obj = sublist.SubList()
assert obj.state == 0
obj.increment()
assert obj.state == 1