Reversed UserLists are not required to support __length_hint__.
This commit is contained in:
parent
6cc14a05d2
commit
2f653c19f4
|
@ -45,7 +45,6 @@ import unittest
|
|||
from test import test_support
|
||||
from itertools import repeat
|
||||
from collections import deque
|
||||
from UserList import UserList
|
||||
from builtins import len as _len
|
||||
|
||||
n = 10
|
||||
|
@ -196,43 +195,6 @@ class TestListReversed(TestInvariantWithoutMutations):
|
|||
d.extend(range(20))
|
||||
self.assertEqual(len(it), 0)
|
||||
|
||||
class TestSeqIter(TestInvariantWithoutMutations):
|
||||
|
||||
def setUp(self):
|
||||
self.it = iter(UserList(range(n)))
|
||||
|
||||
def test_mutation(self):
|
||||
d = UserList(range(n))
|
||||
it = iter(d)
|
||||
next(it)
|
||||
next(it)
|
||||
self.assertEqual(len(it), n-2)
|
||||
d.append(n)
|
||||
self.assertEqual(len(it), n-1) # grow with append
|
||||
d[1:] = []
|
||||
self.assertEqual(len(it), 0)
|
||||
self.assertEqual(list(it), [])
|
||||
d.extend(range(20))
|
||||
self.assertEqual(len(it), 0)
|
||||
|
||||
class TestSeqIterReversed(TestInvariantWithoutMutations):
|
||||
|
||||
def setUp(self):
|
||||
self.it = reversed(UserList(range(n)))
|
||||
|
||||
def test_mutation(self):
|
||||
d = UserList(range(n))
|
||||
it = reversed(d)
|
||||
next(it)
|
||||
next(it)
|
||||
self.assertEqual(len(it), n-2)
|
||||
d.append(n)
|
||||
self.assertEqual(len(it), n-2) # ignore append
|
||||
d[1:] = []
|
||||
self.assertEqual(len(it), 0)
|
||||
self.assertEqual(list(it), []) # confirm invariant
|
||||
d.extend(range(20))
|
||||
self.assertEqual(len(it), 0)
|
||||
|
||||
|
||||
def test_main():
|
||||
|
@ -249,8 +211,6 @@ def test_main():
|
|||
TestSet,
|
||||
TestList,
|
||||
TestListReversed,
|
||||
TestSeqIter,
|
||||
TestSeqIterReversed,
|
||||
]
|
||||
test_support.run_unittest(*unittests)
|
||||
|
||||
|
|
Loading…
Reference in New Issue