diff options
author | Raymond Hettinger <python@rcn.com> | 2016-02-02 05:19:22 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-02-02 05:19:22 (GMT) |
commit | b00da57561505eb220a107fab0e7fbc322f767ac (patch) | |
tree | d781959a29d40965a7cc0aaf4c3a5c8cc03b0411 /Lib/test/test_deque.py | |
parent | 3e7230904e475982d0aea2c0181ea9e04e0ac6b3 (diff) | |
download | cpython-b00da57561505eb220a107fab0e7fbc322f767ac.zip cpython-b00da57561505eb220a107fab0e7fbc322f767ac.tar.gz cpython-b00da57561505eb220a107fab0e7fbc322f767ac.tar.bz2 |
Issue #26194: Inserting into a full deque to raise an IndexError
Diffstat (limited to 'Lib/test/test_deque.py')
-rw-r--r-- | Lib/test/test_deque.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index d2a4633..2ca508d 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -304,19 +304,20 @@ class TestBasic(unittest.TestCase): s.insert(i, 'Z') self.assertEqual(list(d), s) - def test_index_bug_26194(self): + def test_insert_bug_26194(self): data = 'ABC' - for i in range(len(data) + 1): - d = deque(data, len(data)) - d.insert(i, None) - s = list(data) - s.insert(i, None) - s.pop() - self.assertEqual(list(d), s) - if i < len(data): - self.assertIsNone(d[i]) + d = deque(data, maxlen=len(data)) + with self.assertRaises(IndexError): + d.insert(2, None) + + elements = 'ABCDEFGHI' + for i in range(-len(elements), len(elements)): + d = deque(elements, maxlen=len(elements)+1) + d.insert(i, 'Z') + if i >= 0: + self.assertEqual(d[i], 'Z') else: - self.assertTrue(None not in d) + self.assertEqual(d[i-1], 'Z') def test_imul(self): for n in (-10, -1, 0, 1, 2, 10, 1000): |