mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Issue #1283: Allow any iterable of integers to be passed to
bytearray.extend().
This commit is contained in:
parent
b00324f9b4
commit
09121e8eb2
2 changed files with 89 additions and 18 deletions
|
@ -529,6 +529,24 @@ class BytesTest(unittest.TestCase):
|
|||
a.extend(a)
|
||||
self.assertEqual(a, orig + orig)
|
||||
self.assertEqual(a[5:], orig)
|
||||
a = bytearray(b'')
|
||||
# Test iterators that don't have a __length_hint__
|
||||
a.extend(map(int, orig * 25))
|
||||
a.extend(int(x) for x in orig * 25)
|
||||
self.assertEqual(a, orig * 50)
|
||||
self.assertEqual(a[-5:], orig)
|
||||
a = bytearray(b'')
|
||||
a.extend(iter(map(int, orig * 50)))
|
||||
self.assertEqual(a, orig * 50)
|
||||
self.assertEqual(a[-5:], orig)
|
||||
a = bytearray(b'')
|
||||
a.extend(list(map(int, orig * 50)))
|
||||
self.assertEqual(a, orig * 50)
|
||||
self.assertEqual(a[-5:], orig)
|
||||
a = bytearray(b'')
|
||||
self.assertRaises(ValueError, a.extend, [0, 1, 2, 256])
|
||||
self.assertRaises(ValueError, a.extend, [0, 1, 2, -1])
|
||||
self.assertEqual(len(a), 0)
|
||||
|
||||
def test_remove(self):
|
||||
b = bytearray(b'hello')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue