summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_deque.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-01-25 21:32:39 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-01-25 21:32:39 (GMT)
commit512d2cc64328d06f4ff627497ab444e83e513348 (patch)
tree6d3599b5f69310a74dba4eb02c79e91899aba4a0 /Lib/test/test_deque.py
parent5543e8135240cfe4f3d1021c1debe752e3cd7309 (diff)
downloadcpython-512d2cc64328d06f4ff627497ab444e83e513348.zip
cpython-512d2cc64328d06f4ff627497ab444e83e513348.tar.gz
cpython-512d2cc64328d06f4ff627497ab444e83e513348.tar.bz2
Issue #11004: Repair edge case in deque.count().
(Reviewed by Georg Brandl.) Also made similar changes to deque.reverse() though this wasn't strictly necessary (the edge case cannot occur with two pointers moving to meet in the middle). Making the change in reverse() was more a matter of future-proofing.
Diffstat (limited to 'Lib/test/test_deque.py')
-rw-r--r--Lib/test/test_deque.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index da00c0d..0dcadeb 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -138,6 +138,15 @@ class TestBasic(unittest.TestCase):
m.d = d
self.assertRaises(RuntimeError, d.count, 3)
+ # test issue11004
+ # block advance failed after rotation aligned elements on right side of block
+ d = deque([None]*16)
+ for i in range(len(d)):
+ d.rotate(-1)
+ d.rotate(1)
+ self.assertEqual(d.count(1), 0)
+ self.assertEqual(d.count(None), 16)
+
def test_comparisons(self):
d = deque('xabc'); d.popleft()
for e in [d, deque('abc'), deque('ab'), deque(), list(d)]: