6
6
7
7
8
8
class ChoicesTests (TestCase ):
9
- def setUp (self ):
9
+ def setUp (self ) -> None :
10
10
self .STATUS = Choices ('DRAFT' , 'PUBLISHED' )
11
11
12
- def test_getattr (self ):
12
+ def test_getattr (self ) -> None :
13
13
self .assertEqual (self .STATUS .DRAFT , 'DRAFT' )
14
14
15
- def test_indexing (self ):
15
+ def test_indexing (self ) -> None :
16
16
self .assertEqual (self .STATUS ['PUBLISHED' ], 'PUBLISHED' )
17
17
18
- def test_iteration (self ):
18
+ def test_iteration (self ) -> None :
19
19
self .assertEqual (tuple (self .STATUS ),
20
20
(('DRAFT' , 'DRAFT' ), ('PUBLISHED' , 'PUBLISHED' )))
21
21
22
- def test_reversed (self ):
22
+ def test_reversed (self ) -> None :
23
23
self .assertEqual (tuple (reversed (self .STATUS )),
24
24
(('PUBLISHED' , 'PUBLISHED' ), ('DRAFT' , 'DRAFT' )))
25
25
26
- def test_len (self ):
26
+ def test_len (self ) -> None :
27
27
self .assertEqual (len (self .STATUS ), 2 )
28
28
29
- def test_repr (self ):
29
+ def test_repr (self ) -> None :
30
30
self .assertEqual (repr (self .STATUS ), "Choices" + repr ((
31
31
('DRAFT' , 'DRAFT' , 'DRAFT' ),
32
32
('PUBLISHED' , 'PUBLISHED' , 'PUBLISHED' ),
33
33
)))
34
34
35
- def test_wrong_length_tuple (self ):
35
+ def test_wrong_length_tuple (self ) -> None :
36
36
with self .assertRaises (ValueError ):
37
37
Choices (('a' ,))
38
38
39
- def test_contains_value (self ):
39
+ def test_contains_value (self ) -> None :
40
40
self .assertTrue ('PUBLISHED' in self .STATUS )
41
41
self .assertTrue ('DRAFT' in self .STATUS )
42
42
43
- def test_doesnt_contain_value (self ):
43
+ def test_doesnt_contain_value (self ) -> None :
44
44
self .assertFalse ('UNPUBLISHED' in self .STATUS )
45
45
46
- def test_deepcopy (self ):
46
+ def test_deepcopy (self ) -> None :
47
47
import copy
48
48
self .assertEqual (list (self .STATUS ),
49
49
list (copy .deepcopy (self .STATUS )))
50
50
51
- def test_equality (self ):
51
+ def test_equality (self ) -> None :
52
52
self .assertEqual (self .STATUS , Choices ('DRAFT' , 'PUBLISHED' ))
53
53
54
- def test_inequality (self ):
54
+ def test_inequality (self ) -> None :
55
55
self .assertNotEqual (self .STATUS , ['DRAFT' , 'PUBLISHED' ])
56
56
self .assertNotEqual (self .STATUS , Choices ('DRAFT' ))
57
57
58
- def test_composability (self ):
58
+ def test_composability (self ) -> None :
59
59
self .assertEqual (Choices ('DRAFT' ) + Choices ('PUBLISHED' ), self .STATUS )
60
60
self .assertEqual (Choices ('DRAFT' ) + ('PUBLISHED' ,), self .STATUS )
61
61
self .assertEqual (('DRAFT' ,) + Choices ('PUBLISHED' ), self .STATUS )
62
62
63
- def test_option_groups (self ):
63
+ def test_option_groups (self ) -> None :
64
64
c = Choices (('group a' , ['one' , 'two' ]), ['group b' , ('three' ,)])
65
65
self .assertEqual (
66
66
list (c ),
@@ -72,75 +72,75 @@ def test_option_groups(self):
72
72
73
73
74
74
class LabelChoicesTests (ChoicesTests ):
75
- def setUp (self ):
75
+ def setUp (self ) -> None :
76
76
self .STATUS = Choices (
77
77
('DRAFT' , 'is draft' ),
78
78
('PUBLISHED' , 'is published' ),
79
79
'DELETED' ,
80
80
)
81
81
82
- def test_iteration (self ):
82
+ def test_iteration (self ) -> None :
83
83
self .assertEqual (tuple (self .STATUS ), (
84
84
('DRAFT' , 'is draft' ),
85
85
('PUBLISHED' , 'is published' ),
86
86
('DELETED' , 'DELETED' ),
87
87
))
88
88
89
- def test_reversed (self ):
89
+ def test_reversed (self ) -> None :
90
90
self .assertEqual (tuple (reversed (self .STATUS )), (
91
91
('DELETED' , 'DELETED' ),
92
92
('PUBLISHED' , 'is published' ),
93
93
('DRAFT' , 'is draft' ),
94
94
))
95
95
96
- def test_indexing (self ):
96
+ def test_indexing (self ) -> None :
97
97
self .assertEqual (self .STATUS ['PUBLISHED' ], 'is published' )
98
98
99
- def test_default (self ):
99
+ def test_default (self ) -> None :
100
100
self .assertEqual (self .STATUS .DELETED , 'DELETED' )
101
101
102
- def test_provided (self ):
102
+ def test_provided (self ) -> None :
103
103
self .assertEqual (self .STATUS .DRAFT , 'DRAFT' )
104
104
105
- def test_len (self ):
105
+ def test_len (self ) -> None :
106
106
self .assertEqual (len (self .STATUS ), 3 )
107
107
108
- def test_equality (self ):
108
+ def test_equality (self ) -> None :
109
109
self .assertEqual (self .STATUS , Choices (
110
110
('DRAFT' , 'is draft' ),
111
111
('PUBLISHED' , 'is published' ),
112
112
'DELETED' ,
113
113
))
114
114
115
- def test_inequality (self ):
115
+ def test_inequality (self ) -> None :
116
116
self .assertNotEqual (self .STATUS , [
117
117
('DRAFT' , 'is draft' ),
118
118
('PUBLISHED' , 'is published' ),
119
119
'DELETED'
120
120
])
121
121
self .assertNotEqual (self .STATUS , Choices ('DRAFT' ))
122
122
123
- def test_repr (self ):
123
+ def test_repr (self ) -> None :
124
124
self .assertEqual (repr (self .STATUS ), "Choices" + repr ((
125
125
('DRAFT' , 'DRAFT' , 'is draft' ),
126
126
('PUBLISHED' , 'PUBLISHED' , 'is published' ),
127
127
('DELETED' , 'DELETED' , 'DELETED' ),
128
128
)))
129
129
130
- def test_contains_value (self ):
130
+ def test_contains_value (self ) -> None :
131
131
self .assertTrue ('PUBLISHED' in self .STATUS )
132
132
self .assertTrue ('DRAFT' in self .STATUS )
133
133
# This should be True, because both the display value
134
134
# and the internal representation are both DELETED.
135
135
self .assertTrue ('DELETED' in self .STATUS )
136
136
137
- def test_doesnt_contain_value (self ):
137
+ def test_doesnt_contain_value (self ) -> None :
138
138
self .assertFalse ('UNPUBLISHED' in self .STATUS )
139
139
140
- def test_doesnt_contain_display_value (self ):
140
+ def test_doesnt_contain_display_value (self ) -> None :
141
141
self .assertFalse ('is draft' in self .STATUS )
142
142
143
- def test_composability (self ):
143
+ def test_composability (self ) -> None :
144
144
self .assertEqual (
145
145
Choices (('DRAFT' , 'is draft' ,)) + Choices (('PUBLISHED' , 'is published' ), 'DELETED' ),
146
146
self .STATUS
@@ -156,7 +156,7 @@ def test_composability(self):
156
156
self .STATUS
157
157
)
158
158
159
- def test_option_groups (self ):
159
+ def test_option_groups (self ) -> None :
160
160
c = Choices (
161
161
('group a' , [(1 , 'one' ), (2 , 'two' )]),
162
162
['group b' , ((3 , 'three' ),)]
@@ -171,72 +171,72 @@ def test_option_groups(self):
171
171
172
172
173
173
class IdentifierChoicesTests (ChoicesTests ):
174
- def setUp (self ):
174
+ def setUp (self ) -> None :
175
175
self .STATUS = Choices (
176
176
(0 , 'DRAFT' , 'is draft' ),
177
177
(1 , 'PUBLISHED' , 'is published' ),
178
178
(2 , 'DELETED' , 'is deleted' ))
179
179
180
- def test_iteration (self ):
180
+ def test_iteration (self ) -> None :
181
181
self .assertEqual (tuple (self .STATUS ), (
182
182
(0 , 'is draft' ),
183
183
(1 , 'is published' ),
184
184
(2 , 'is deleted' ),
185
185
))
186
186
187
- def test_reversed (self ):
187
+ def test_reversed (self ) -> None :
188
188
self .assertEqual (tuple (reversed (self .STATUS )), (
189
189
(2 , 'is deleted' ),
190
190
(1 , 'is published' ),
191
191
(0 , 'is draft' ),
192
192
))
193
193
194
- def test_indexing (self ):
194
+ def test_indexing (self ) -> None :
195
195
self .assertEqual (self .STATUS [1 ], 'is published' )
196
196
197
- def test_getattr (self ):
197
+ def test_getattr (self ) -> None :
198
198
self .assertEqual (self .STATUS .DRAFT , 0 )
199
199
200
- def test_len (self ):
200
+ def test_len (self ) -> None :
201
201
self .assertEqual (len (self .STATUS ), 3 )
202
202
203
- def test_repr (self ):
203
+ def test_repr (self ) -> None :
204
204
self .assertEqual (repr (self .STATUS ), "Choices" + repr ((
205
205
(0 , 'DRAFT' , 'is draft' ),
206
206
(1 , 'PUBLISHED' , 'is published' ),
207
207
(2 , 'DELETED' , 'is deleted' ),
208
208
)))
209
209
210
- def test_contains_value (self ):
210
+ def test_contains_value (self ) -> None :
211
211
self .assertTrue (0 in self .STATUS )
212
212
self .assertTrue (1 in self .STATUS )
213
213
self .assertTrue (2 in self .STATUS )
214
214
215
- def test_doesnt_contain_value (self ):
215
+ def test_doesnt_contain_value (self ) -> None :
216
216
self .assertFalse (3 in self .STATUS )
217
217
218
- def test_doesnt_contain_display_value (self ):
218
+ def test_doesnt_contain_display_value (self ) -> None :
219
219
self .assertFalse ('is draft' in self .STATUS )
220
220
221
- def test_doesnt_contain_python_attr (self ):
221
+ def test_doesnt_contain_python_attr (self ) -> None :
222
222
self .assertFalse ('PUBLISHED' in self .STATUS )
223
223
224
- def test_equality (self ):
224
+ def test_equality (self ) -> None :
225
225
self .assertEqual (self .STATUS , Choices (
226
226
(0 , 'DRAFT' , 'is draft' ),
227
227
(1 , 'PUBLISHED' , 'is published' ),
228
228
(2 , 'DELETED' , 'is deleted' )
229
229
))
230
230
231
- def test_inequality (self ):
231
+ def test_inequality (self ) -> None :
232
232
self .assertNotEqual (self .STATUS , [
233
233
(0 , 'DRAFT' , 'is draft' ),
234
234
(1 , 'PUBLISHED' , 'is published' ),
235
235
(2 , 'DELETED' , 'is deleted' )
236
236
])
237
237
self .assertNotEqual (self .STATUS , Choices ('DRAFT' ))
238
238
239
- def test_composability (self ):
239
+ def test_composability (self ) -> None :
240
240
self .assertEqual (
241
241
Choices (
242
242
(0 , 'DRAFT' , 'is draft' ),
@@ -267,7 +267,7 @@ def test_composability(self):
267
267
self .STATUS
268
268
)
269
269
270
- def test_option_groups (self ):
270
+ def test_option_groups (self ) -> None :
271
271
c = Choices (
272
272
('group a' , [(1 , 'ONE' , 'one' ), (2 , 'TWO' , 'two' )]),
273
273
['group b' , ((3 , 'THREE' , 'three' ),)]
@@ -283,26 +283,26 @@ def test_option_groups(self):
283
283
284
284
class SubsetChoicesTest (TestCase ):
285
285
286
- def setUp (self ):
286
+ def setUp (self ) -> None :
287
287
self .choices = Choices (
288
288
(0 , 'a' , 'A' ),
289
289
(1 , 'b' , 'B' ),
290
290
)
291
291
292
- def test_nonexistent_identifiers_raise (self ):
292
+ def test_nonexistent_identifiers_raise (self ) -> None :
293
293
with self .assertRaises (ValueError ):
294
294
self .choices .subset ('a' , 'c' )
295
295
296
- def test_solo_nonexistent_identifiers_raise (self ):
296
+ def test_solo_nonexistent_identifiers_raise (self ) -> None :
297
297
with self .assertRaises (ValueError ):
298
298
self .choices .subset ('c' )
299
299
300
- def test_empty_subset_passes (self ):
300
+ def test_empty_subset_passes (self ) -> None :
301
301
subset = self .choices .subset ()
302
302
303
303
self .assertEqual (subset , Choices ())
304
304
305
- def test_subset_returns_correct_subset (self ):
305
+ def test_subset_returns_correct_subset (self ) -> None :
306
306
subset = self .choices .subset ('a' )
307
307
308
308
self .assertEqual (subset , Choices ((0 , 'a' , 'A' )))
0 commit comments