summaryrefslogtreecommitdiff
path: root/Lib/test/test_deque.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-09-19 09:05:42 -0700
committerRaymond Hettinger <python@rcn.com>2015-09-19 09:05:42 -0700
commitd46a2718abd0798929ada1b1affc122daf3e004e (patch)
treeafc60bc1cc7d1711d4381fadfb2edae89663f991 /Lib/test/test_deque.py
parent1d834017276f5853339b0d9bf0bf2efed5105280 (diff)
downloadcpython-d46a2718abd0798929ada1b1affc122daf3e004e.tar.gz
Add a fast path (no iterator creation) for a common case for repeating deques of size 1
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 87187161ab..c61e80bc2e 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -654,6 +654,15 @@ class TestBasic(unittest.TestCase):
self.assertNotEqual(id(d), id(e))
self.assertEqual(list(d), list(e))
+ for i in range(5):
+ for maxlen in range(-1, 6):
+ s = [random.random() for j in range(i)]
+ d = deque(s) if maxlen == -1 else deque(s, maxlen)
+ e = d.copy()
+ self.assertEqual(d, e)
+ self.assertEqual(d.maxlen, e.maxlen)
+ self.assertTrue(all(x is y for x, y in zip(d, e)))
+
def test_copy_method(self):
mut = [10]
d = deque([mut])