summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-12-10 00:47:21 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-12-10 00:47:21 (GMT)
commite5fdedbeda147f3878f82349464f28f184c01658 (patch)
treeb7a53644e818a23a1207de853919654d2398b729 /Lib
parent3e761a98026731d24f3e54cca2f96dc2cf5fa575 (diff)
downloadcpython-e5fdedbeda147f3878f82349464f28f184c01658.zip
cpython-e5fdedbeda147f3878f82349464f28f184c01658.tar.gz
cpython-e5fdedbeda147f3878f82349464f28f184c01658.tar.bz2
Add a reverse() method to collections.deque().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_deque.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 1a03188..cdb0dab 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -193,6 +193,18 @@ class TestBasic(unittest.TestCase):
self.assertTrue(val not in d)
self.assertEqual(len(d), 0)
+ def test_reverse(self):
+ n = 500 # O(n**2) test, don't make this too big
+ data = [random.random() for i in range(n)]
+ for i in range(n):
+ d = deque(data[:i])
+ r = d.reverse()
+ self.assertEqual(list(d), list(reversed(data[:i])))
+ self.assert_(r is None)
+ d.reverse()
+ self.assertEqual(list(d), data[:i])
+ self.assertRaises(TypeError, d.reverse, 1) # Arity is zero
+
def test_rotate(self):
s = tuple('abcde')
n = len(s)