66
77
88class ChoicesTests (TestCase ):
9- def setUp (self ):
9+ def setUp (self ) -> None :
1010 self .STATUS = Choices ('DRAFT' , 'PUBLISHED' )
1111
12- def test_getattr (self ):
12+ def test_getattr (self ) -> None :
1313 self .assertEqual (self .STATUS .DRAFT , 'DRAFT' )
1414
15- def test_indexing (self ):
15+ def test_indexing (self ) -> None :
1616 self .assertEqual (self .STATUS ['PUBLISHED' ], 'PUBLISHED' )
1717
18- def test_iteration (self ):
18+ def test_iteration (self ) -> None :
1919 self .assertEqual (tuple (self .STATUS ),
2020 (('DRAFT' , 'DRAFT' ), ('PUBLISHED' , 'PUBLISHED' )))
2121
22- def test_reversed (self ):
22+ def test_reversed (self ) -> None :
2323 self .assertEqual (tuple (reversed (self .STATUS )),
2424 (('PUBLISHED' , 'PUBLISHED' ), ('DRAFT' , 'DRAFT' )))
2525
26- def test_len (self ):
26+ def test_len (self ) -> None :
2727 self .assertEqual (len (self .STATUS ), 2 )
2828
29- def test_repr (self ):
29+ def test_repr (self ) -> None :
3030 self .assertEqual (repr (self .STATUS ), "Choices" + repr ((
3131 ('DRAFT' , 'DRAFT' , 'DRAFT' ),
3232 ('PUBLISHED' , 'PUBLISHED' , 'PUBLISHED' ),
3333 )))
3434
35- def test_wrong_length_tuple (self ):
35+ def test_wrong_length_tuple (self ) -> None :
3636 with self .assertRaises (ValueError ):
3737 Choices (('a' ,))
3838
39- def test_contains_value (self ):
39+ def test_contains_value (self ) -> None :
4040 self .assertTrue ('PUBLISHED' in self .STATUS )
4141 self .assertTrue ('DRAFT' in self .STATUS )
4242
43- def test_doesnt_contain_value (self ):
43+ def test_doesnt_contain_value (self ) -> None :
4444 self .assertFalse ('UNPUBLISHED' in self .STATUS )
4545
46- def test_deepcopy (self ):
46+ def test_deepcopy (self ) -> None :
4747 import copy
4848 self .assertEqual (list (self .STATUS ),
4949 list (copy .deepcopy (self .STATUS )))
5050
51- def test_equality (self ):
51+ def test_equality (self ) -> None :
5252 self .assertEqual (self .STATUS , Choices ('DRAFT' , 'PUBLISHED' ))
5353
54- def test_inequality (self ):
54+ def test_inequality (self ) -> None :
5555 self .assertNotEqual (self .STATUS , ['DRAFT' , 'PUBLISHED' ])
5656 self .assertNotEqual (self .STATUS , Choices ('DRAFT' ))
5757
58- def test_composability (self ):
58+ def test_composability (self ) -> None :
5959 self .assertEqual (Choices ('DRAFT' ) + Choices ('PUBLISHED' ), self .STATUS )
6060 self .assertEqual (Choices ('DRAFT' ) + ('PUBLISHED' ,), self .STATUS )
6161 self .assertEqual (('DRAFT' ,) + Choices ('PUBLISHED' ), self .STATUS )
6262
63- def test_option_groups (self ):
63+ def test_option_groups (self ) -> None :
6464 c = Choices (('group a' , ['one' , 'two' ]), ['group b' , ('three' ,)])
6565 self .assertEqual (
6666 list (c ),
@@ -72,75 +72,75 @@ def test_option_groups(self):
7272
7373
7474class LabelChoicesTests (ChoicesTests ):
75- def setUp (self ):
75+ def setUp (self ) -> None :
7676 self .STATUS = Choices (
7777 ('DRAFT' , 'is draft' ),
7878 ('PUBLISHED' , 'is published' ),
7979 'DELETED' ,
8080 )
8181
82- def test_iteration (self ):
82+ def test_iteration (self ) -> None :
8383 self .assertEqual (tuple (self .STATUS ), (
8484 ('DRAFT' , 'is draft' ),
8585 ('PUBLISHED' , 'is published' ),
8686 ('DELETED' , 'DELETED' ),
8787 ))
8888
89- def test_reversed (self ):
89+ def test_reversed (self ) -> None :
9090 self .assertEqual (tuple (reversed (self .STATUS )), (
9191 ('DELETED' , 'DELETED' ),
9292 ('PUBLISHED' , 'is published' ),
9393 ('DRAFT' , 'is draft' ),
9494 ))
9595
96- def test_indexing (self ):
96+ def test_indexing (self ) -> None :
9797 self .assertEqual (self .STATUS ['PUBLISHED' ], 'is published' )
9898
99- def test_default (self ):
99+ def test_default (self ) -> None :
100100 self .assertEqual (self .STATUS .DELETED , 'DELETED' )
101101
102- def test_provided (self ):
102+ def test_provided (self ) -> None :
103103 self .assertEqual (self .STATUS .DRAFT , 'DRAFT' )
104104
105- def test_len (self ):
105+ def test_len (self ) -> None :
106106 self .assertEqual (len (self .STATUS ), 3 )
107107
108- def test_equality (self ):
108+ def test_equality (self ) -> None :
109109 self .assertEqual (self .STATUS , Choices (
110110 ('DRAFT' , 'is draft' ),
111111 ('PUBLISHED' , 'is published' ),
112112 'DELETED' ,
113113 ))
114114
115- def test_inequality (self ):
115+ def test_inequality (self ) -> None :
116116 self .assertNotEqual (self .STATUS , [
117117 ('DRAFT' , 'is draft' ),
118118 ('PUBLISHED' , 'is published' ),
119119 'DELETED'
120120 ])
121121 self .assertNotEqual (self .STATUS , Choices ('DRAFT' ))
122122
123- def test_repr (self ):
123+ def test_repr (self ) -> None :
124124 self .assertEqual (repr (self .STATUS ), "Choices" + repr ((
125125 ('DRAFT' , 'DRAFT' , 'is draft' ),
126126 ('PUBLISHED' , 'PUBLISHED' , 'is published' ),
127127 ('DELETED' , 'DELETED' , 'DELETED' ),
128128 )))
129129
130- def test_contains_value (self ):
130+ def test_contains_value (self ) -> None :
131131 self .assertTrue ('PUBLISHED' in self .STATUS )
132132 self .assertTrue ('DRAFT' in self .STATUS )
133133 # This should be True, because both the display value
134134 # and the internal representation are both DELETED.
135135 self .assertTrue ('DELETED' in self .STATUS )
136136
137- def test_doesnt_contain_value (self ):
137+ def test_doesnt_contain_value (self ) -> None :
138138 self .assertFalse ('UNPUBLISHED' in self .STATUS )
139139
140- def test_doesnt_contain_display_value (self ):
140+ def test_doesnt_contain_display_value (self ) -> None :
141141 self .assertFalse ('is draft' in self .STATUS )
142142
143- def test_composability (self ):
143+ def test_composability (self ) -> None :
144144 self .assertEqual (
145145 Choices (('DRAFT' , 'is draft' ,)) + Choices (('PUBLISHED' , 'is published' ), 'DELETED' ),
146146 self .STATUS
@@ -156,7 +156,7 @@ def test_composability(self):
156156 self .STATUS
157157 )
158158
159- def test_option_groups (self ):
159+ def test_option_groups (self ) -> None :
160160 c = Choices (
161161 ('group a' , [(1 , 'one' ), (2 , 'two' )]),
162162 ['group b' , ((3 , 'three' ),)]
@@ -171,72 +171,72 @@ def test_option_groups(self):
171171
172172
173173class IdentifierChoicesTests (ChoicesTests ):
174- def setUp (self ):
174+ def setUp (self ) -> None :
175175 self .STATUS = Choices (
176176 (0 , 'DRAFT' , 'is draft' ),
177177 (1 , 'PUBLISHED' , 'is published' ),
178178 (2 , 'DELETED' , 'is deleted' ))
179179
180- def test_iteration (self ):
180+ def test_iteration (self ) -> None :
181181 self .assertEqual (tuple (self .STATUS ), (
182182 (0 , 'is draft' ),
183183 (1 , 'is published' ),
184184 (2 , 'is deleted' ),
185185 ))
186186
187- def test_reversed (self ):
187+ def test_reversed (self ) -> None :
188188 self .assertEqual (tuple (reversed (self .STATUS )), (
189189 (2 , 'is deleted' ),
190190 (1 , 'is published' ),
191191 (0 , 'is draft' ),
192192 ))
193193
194- def test_indexing (self ):
194+ def test_indexing (self ) -> None :
195195 self .assertEqual (self .STATUS [1 ], 'is published' )
196196
197- def test_getattr (self ):
197+ def test_getattr (self ) -> None :
198198 self .assertEqual (self .STATUS .DRAFT , 0 )
199199
200- def test_len (self ):
200+ def test_len (self ) -> None :
201201 self .assertEqual (len (self .STATUS ), 3 )
202202
203- def test_repr (self ):
203+ def test_repr (self ) -> None :
204204 self .assertEqual (repr (self .STATUS ), "Choices" + repr ((
205205 (0 , 'DRAFT' , 'is draft' ),
206206 (1 , 'PUBLISHED' , 'is published' ),
207207 (2 , 'DELETED' , 'is deleted' ),
208208 )))
209209
210- def test_contains_value (self ):
210+ def test_contains_value (self ) -> None :
211211 self .assertTrue (0 in self .STATUS )
212212 self .assertTrue (1 in self .STATUS )
213213 self .assertTrue (2 in self .STATUS )
214214
215- def test_doesnt_contain_value (self ):
215+ def test_doesnt_contain_value (self ) -> None :
216216 self .assertFalse (3 in self .STATUS )
217217
218- def test_doesnt_contain_display_value (self ):
218+ def test_doesnt_contain_display_value (self ) -> None :
219219 self .assertFalse ('is draft' in self .STATUS )
220220
221- def test_doesnt_contain_python_attr (self ):
221+ def test_doesnt_contain_python_attr (self ) -> None :
222222 self .assertFalse ('PUBLISHED' in self .STATUS )
223223
224- def test_equality (self ):
224+ def test_equality (self ) -> None :
225225 self .assertEqual (self .STATUS , Choices (
226226 (0 , 'DRAFT' , 'is draft' ),
227227 (1 , 'PUBLISHED' , 'is published' ),
228228 (2 , 'DELETED' , 'is deleted' )
229229 ))
230230
231- def test_inequality (self ):
231+ def test_inequality (self ) -> None :
232232 self .assertNotEqual (self .STATUS , [
233233 (0 , 'DRAFT' , 'is draft' ),
234234 (1 , 'PUBLISHED' , 'is published' ),
235235 (2 , 'DELETED' , 'is deleted' )
236236 ])
237237 self .assertNotEqual (self .STATUS , Choices ('DRAFT' ))
238238
239- def test_composability (self ):
239+ def test_composability (self ) -> None :
240240 self .assertEqual (
241241 Choices (
242242 (0 , 'DRAFT' , 'is draft' ),
@@ -267,7 +267,7 @@ def test_composability(self):
267267 self .STATUS
268268 )
269269
270- def test_option_groups (self ):
270+ def test_option_groups (self ) -> None :
271271 c = Choices (
272272 ('group a' , [(1 , 'ONE' , 'one' ), (2 , 'TWO' , 'two' )]),
273273 ['group b' , ((3 , 'THREE' , 'three' ),)]
@@ -283,26 +283,26 @@ def test_option_groups(self):
283283
284284class SubsetChoicesTest (TestCase ):
285285
286- def setUp (self ):
286+ def setUp (self ) -> None :
287287 self .choices = Choices (
288288 (0 , 'a' , 'A' ),
289289 (1 , 'b' , 'B' ),
290290 )
291291
292- def test_nonexistent_identifiers_raise (self ):
292+ def test_nonexistent_identifiers_raise (self ) -> None :
293293 with self .assertRaises (ValueError ):
294294 self .choices .subset ('a' , 'c' )
295295
296- def test_solo_nonexistent_identifiers_raise (self ):
296+ def test_solo_nonexistent_identifiers_raise (self ) -> None :
297297 with self .assertRaises (ValueError ):
298298 self .choices .subset ('c' )
299299
300- def test_empty_subset_passes (self ):
300+ def test_empty_subset_passes (self ) -> None :
301301 subset = self .choices .subset ()
302302
303303 self .assertEqual (subset , Choices ())
304304
305- def test_subset_returns_correct_subset (self ):
305+ def test_subset_returns_correct_subset (self ) -> None :
306306 subset = self .choices .subset ('a' )
307307
308308 self .assertEqual (subset , Choices ((0 , 'a' , 'A' )))
0 commit comments