diff options
author | Raymond Hettinger <python@rcn.com> | 2009-12-10 00:47:21 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-12-10 00:47:21 (GMT) |
commit | e5fdedbeda147f3878f82349464f28f184c01658 (patch) | |
tree | b7a53644e818a23a1207de853919654d2398b729 /Lib | |
parent | 3e761a98026731d24f3e54cca2f96dc2cf5fa575 (diff) | |
download | cpython-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.py | 12 |
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) |