diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2007-12-04 05:51:13 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2007-12-04 05:51:13 (GMT) |
commit | 09121e8eb252d8164d93a12552c832b9bf2e0117 (patch) | |
tree | e15529d9bacd5ebd940ac8426f4eb49981c79794 /Lib/test/test_bytes.py | |
parent | b00324f9b45c677def6c9248ba49ccd56f738beb (diff) | |
download | cpython-09121e8eb252d8164d93a12552c832b9bf2e0117.zip cpython-09121e8eb252d8164d93a12552c832b9bf2e0117.tar.gz cpython-09121e8eb252d8164d93a12552c832b9bf2e0117.tar.bz2 |
Issue #1283: Allow any iterable of integers to be passed to
bytearray.extend().
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 659afac..f037d4c 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -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') |