mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Merge r60628, r60631, and r60633. Register UserList and UserString will the appropriate ABCs.
This commit is contained in:
parent
017b6a3ad2
commit
882a416900
3 changed files with 14 additions and 45 deletions
|
|
@ -45,7 +45,6 @@ import unittest
|
|||
from test import test_support
|
||||
from itertools import repeat
|
||||
from collections import deque
|
||||
from UserList import UserList
|
||||
from __builtin__ import len as _len
|
||||
|
||||
n = 10
|
||||
|
|
@ -196,45 +195,6 @@ class TestListReversed(TestInvariantWithoutMutations):
|
|||
d.extend(xrange(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)
|
||||
it.next()
|
||||
it.next()
|
||||
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(xrange(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)
|
||||
it.next()
|
||||
it.next()
|
||||
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(xrange(20))
|
||||
self.assertEqual(len(it), 0)
|
||||
|
||||
|
||||
def test_main():
|
||||
unittests = [
|
||||
TestRepeat,
|
||||
|
|
@ -249,8 +209,6 @@ def test_main():
|
|||
TestSet,
|
||||
TestList,
|
||||
TestListReversed,
|
||||
TestSeqIter,
|
||||
TestSeqIterReversed,
|
||||
]
|
||||
test_support.run_unittest(*unittests)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue