3
3
import sys
4
4
import unittest
5
5
from test .support import run_unittest , TESTFN , unlink , cpython_only
6
- from test .support import check_free_after_iterating
6
+ # from test.support import check_free_after_iterating
7
7
import pickle
8
8
import collections .abc
9
9
@@ -109,6 +109,8 @@ def check_pickle(self, itorg, seq):
109
109
self .assertEqual (list (it ), seq [1 :])
110
110
111
111
# Test basic use of iter() function
112
+ # TODO: RUSTPYTHON
113
+ @unittest .expectedFailure
112
114
def test_iter_basic (self ):
113
115
self .check_iterator (iter (range (10 )), list (range (10 )))
114
116
@@ -120,6 +122,8 @@ def test_iter_idempotency(self):
120
122
self .assertTrue (it is it2 )
121
123
122
124
# Test that for loops over iterators work
125
+ # TODO: RUSTPYTHON
126
+ @unittest .expectedFailure
123
127
def test_iter_for_loop (self ):
124
128
self .check_for_loop (iter (range (10 )), list (range (10 )))
125
129
@@ -147,21 +151,31 @@ def test_nested_comprehensions_for(self):
147
151
self .assertEqual (res , TRIPLETS )
148
152
149
153
# Test a class with __iter__ in a for loop
154
+ # TODO: RUSTPYTHON
155
+ @unittest .expectedFailure
150
156
def test_iter_class_for (self ):
151
157
self .check_for_loop (IteratingSequenceClass (10 ), list (range (10 )))
152
158
153
159
# Test a class with __iter__ with explicit iter()
160
+ # TODO: RUSTPYTHON
161
+ @unittest .expectedFailure
154
162
def test_iter_class_iter (self ):
155
163
self .check_iterator (iter (IteratingSequenceClass (10 )), list (range (10 )))
156
164
157
165
# Test for loop on a sequence class without __iter__
166
+ # TODO: RUSTPYTHON
167
+ @unittest .expectedFailure
158
168
def test_seq_class_for (self ):
159
169
self .check_for_loop (SequenceClass (10 ), list (range (10 )))
160
170
161
171
# Test iter() on a sequence class without __iter__
172
+ # TODO: RUSTPYTHON
173
+ @unittest .expectedFailure
162
174
def test_seq_class_iter (self ):
163
175
self .check_iterator (iter (SequenceClass (10 )), list (range (10 )))
164
176
177
+ # TODO: RUSTPYTHON
178
+ @unittest .expectedFailure
165
179
def test_mutating_seq_class_iter_pickle (self ):
166
180
orig = SequenceClass (5 )
167
181
for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
@@ -198,6 +212,8 @@ def test_mutating_seq_class_iter_pickle(self):
198
212
self .assertTrue (isinstance (it , collections .abc .Iterator ))
199
213
self .assertEqual (list (it ), [])
200
214
215
+ # TODO: RUSTPYTHON
216
+ @unittest .expectedFailure
201
217
def test_mutating_seq_class_exhausted_iter (self ):
202
218
a = SequenceClass (5 )
203
219
exhit = iter (a )
@@ -210,13 +226,17 @@ def test_mutating_seq_class_exhausted_iter(self):
210
226
self .assertEqual (list (a ), [0 , 1 , 2 , 3 , 4 , 5 , 6 ])
211
227
212
228
# Test a new_style class with __iter__ but no next() method
229
+ # TODO: RUSTPYTHON
230
+ @unittest .expectedFailure
213
231
def test_new_style_iter_class (self ):
214
232
class IterClass (object ):
215
233
def __iter__ (self ):
216
234
return self
217
235
self .assertRaises (TypeError , iter , IterClass ())
218
236
219
237
# Test two-argument iter() with callable instance
238
+ # TODO: RUSTPYTHON
239
+ @unittest .expectedFailure
220
240
def test_iter_callable (self ):
221
241
class C :
222
242
def __init__ (self ):
@@ -230,6 +250,8 @@ def __call__(self):
230
250
self .check_iterator (iter (C (), 10 ), list (range (10 )), pickle = False )
231
251
232
252
# Test two-argument iter() with function
253
+ # TODO: RUSTPYTHON
254
+ @unittest .expectedFailure
233
255
def test_iter_function (self ):
234
256
def spam (state = [0 ]):
235
257
i = state [0 ]
@@ -238,6 +260,8 @@ def spam(state=[0]):
238
260
self .check_iterator (iter (spam , 10 ), list (range (10 )), pickle = False )
239
261
240
262
# Test two-argument iter() with function that raises StopIteration
263
+ # TODO: RUSTPYTHON
264
+ @unittest .expectedFailure
241
265
def test_iter_function_stop (self ):
242
266
def spam (state = [0 ]):
243
267
i = state [0 ]
@@ -248,6 +272,8 @@ def spam(state=[0]):
248
272
self .check_iterator (iter (spam , 20 ), list (range (10 )), pickle = False )
249
273
250
274
# Test exception propagation through function iterator
275
+ # TODO: RUSTPYTHON
276
+ @unittest .expectedFailure
251
277
def test_exception_function (self ):
252
278
def spam (state = [0 ]):
253
279
i = state [0 ]
@@ -290,26 +316,38 @@ def __getitem__(self, i):
290
316
self .check_for_loop (MySequenceClass (20 ), list (range (10 )), pickle = False )
291
317
292
318
# Test a big range
319
+ # TODO: RUSTPYTHON
320
+ @unittest .expectedFailure
293
321
def test_iter_big_range (self ):
294
322
self .check_for_loop (iter (range (10000 )), list (range (10000 )))
295
323
296
324
# Test an empty list
325
+ # TODO: RUSTPYTHON
326
+ @unittest .expectedFailure
297
327
def test_iter_empty (self ):
298
328
self .check_for_loop (iter ([]), [])
299
329
300
330
# Test a tuple
331
+ # TODO: RUSTPYTHON
332
+ @unittest .expectedFailure
301
333
def test_iter_tuple (self ):
302
334
self .check_for_loop (iter ((0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 )), list (range (10 )))
303
335
304
336
# Test a range
337
+ # TODO: RUSTPYTHON
338
+ @unittest .expectedFailure
305
339
def test_iter_range (self ):
306
340
self .check_for_loop (iter (range (10 )), list (range (10 )))
307
341
308
342
# Test a string
343
+ # TODO: RUSTPYTHON
344
+ @unittest .expectedFailure
309
345
def test_iter_string (self ):
310
346
self .check_for_loop (iter ("abcde" ), ["a" , "b" , "c" , "d" , "e" ])
311
347
312
348
# Test a directory
349
+ # TODO: RUSTPYTHON
350
+ @unittest .expectedFailure
313
351
def test_iter_dict (self ):
314
352
dict = {}
315
353
for i in range (10 ):
@@ -336,6 +374,8 @@ def test_iter_file(self):
336
374
pass
337
375
338
376
# Test list()'s use of iterators.
377
+ # TODO: RUSTPYTHON
378
+ @unittest .expectedFailure
339
379
def test_builtin_list (self ):
340
380
self .assertEqual (list (SequenceClass (5 )), list (range (5 )))
341
381
self .assertEqual (list (SequenceClass (0 )), [])
@@ -367,6 +407,8 @@ def test_builtin_list(self):
367
407
pass
368
408
369
409
# Test tuples()'s use of iterators.
410
+ # TODO: RUSTPYTHON
411
+ @unittest .expectedFailure
370
412
def test_builtin_tuple (self ):
371
413
self .assertEqual (tuple (SequenceClass (5 )), (0 , 1 , 2 , 3 , 4 ))
372
414
self .assertEqual (tuple (SequenceClass (0 )), ())
@@ -445,6 +487,8 @@ def __next__(self):
445
487
self .assertEqual (list (filter (lambda x : not x , iter (seq ))), [bFalse ]* 25 )
446
488
447
489
# Test max() and min()'s use of iterators.
490
+ # TODO: RUSTPYTHON
491
+ @unittest .expectedFailure
448
492
def test_builtin_max_min (self ):
449
493
self .assertEqual (max (SequenceClass (5 )), 4 )
450
494
self .assertEqual (min (SequenceClass (5 )), 0 )
@@ -628,6 +672,8 @@ def __next__(self):
628
672
pass
629
673
630
674
# Test iterators with 'x in y' and 'x not in y'.
675
+ # TODO: RUSTPYTHON
676
+ @unittest .expectedFailure
631
677
def test_in_and_not_in (self ):
632
678
for sc5 in IteratingSequenceClass (5 ), SequenceClass (5 ):
633
679
for i in range (5 ):
@@ -669,6 +715,8 @@ def test_in_and_not_in(self):
669
715
pass
670
716
671
717
# Test iterators with operator.countOf (PySequence_Count).
718
+ # TODO: RUSTPYTHON
719
+ @unittest .expectedFailure
672
720
def test_countOf (self ):
673
721
from operator import countOf
674
722
self .assertEqual (countOf ([1 ,2 ,2 ,3 ,2 ,5 ], 2 ), 3 )
@@ -745,6 +793,8 @@ def test_indexOf(self):
745
793
self .assertRaises (ValueError , indexOf , iclass , - 1 )
746
794
747
795
# Test iterators with file.writelines().
796
+ # TODO: RUSTPYTHON
797
+ @unittest .expectedFailure
748
798
def test_writelines (self ):
749
799
f = open (TESTFN , "w" )
750
800
@@ -880,6 +930,8 @@ def __del__(self):
880
930
# This tests various things that weren't sink states in Python 2.2.1,
881
931
# plus various things that always were fine.
882
932
933
+ # TODO: RUSTPYTHON
934
+ @unittest .expectedFailure
883
935
def test_sinkstate_list (self ):
884
936
# This used to fail
885
937
a = list (range (5 ))
@@ -900,6 +952,8 @@ def test_sinkstate_string(self):
900
952
self .assertEqual (list (b ), ['a' , 'b' , 'c' , 'd' , 'e' ])
901
953
self .assertEqual (list (b ), [])
902
954
955
+ # TODO: RUSTPYTHON
956
+ @unittest .expectedFailure
903
957
def test_sinkstate_sequence (self ):
904
958
# This used to fail
905
959
a = SequenceClass (5 )
@@ -908,6 +962,8 @@ def test_sinkstate_sequence(self):
908
962
a .n = 10
909
963
self .assertEqual (list (b ), [])
910
964
965
+ # TODO: RUSTPYTHON
966
+ @unittest .expectedFailure
911
967
def test_sinkstate_callable (self ):
912
968
# This used to fail
913
969
def spam (state = [0 ]):
@@ -994,12 +1050,15 @@ def test_iter_overflow(self):
994
1050
with self .assertRaises (OverflowError ):
995
1051
next (it )
996
1052
1053
+ # TODO: RUSTPYTHON
1054
+ @unittest .expectedFailure
997
1055
def test_iter_neg_setstate (self ):
998
1056
it = iter (UnlimitedSequenceClass ())
999
1057
it .__setstate__ (- 42 )
1000
1058
self .assertEqual (next (it ), 0 )
1001
1059
self .assertEqual (next (it ), 1 )
1002
1060
1061
+ @unittest .skip ("TODO: RUSTPYTHON" )
1003
1062
def test_free_after_iterating (self ):
1004
1063
check_free_after_iterating (self , iter , SequenceClass , (0 ,))
1005
1064
0 commit comments