summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_deque.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-09-19 16:05:42 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-09-19 16:05:42 (GMT)
commitaed8830af3bb5a79878cf0f603ebbd8a37f5b36e (patch)
tree2bee70c7e080f51316196a635b70ddd2910cbada /Lib/test/test_deque.py
parent026977717eea2382590547d476abcb0c74391358 (diff)
downloadcpython-aed8830af3bb5a79878cf0f603ebbd8a37f5b36e.zip
cpython-aed8830af3bb5a79878cf0f603ebbd8a37f5b36e.tar.gz
cpython-aed8830af3bb5a79878cf0f603ebbd8a37f5b36e.tar.bz2
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 8718716..c61e80b 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])