diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-03 19:22:41 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-03 19:22:41 (GMT) |
commit | 7376801f61330d8053c9393da813a3092f881634 (patch) | |
tree | bd6ae0bbaf488e4147acbf3d0555e5cf120083d6 /Lib/test/test_bytes.py | |
parent | 1c8bb9f4d5478c4bc7e1b9dfa291753b184c2605 (diff) | |
parent | c64bcbec4bb3cdad320184b4155cdc05c55bb10d (diff) | |
download | cpython-7376801f61330d8053c9393da813a3092f881634.zip cpython-7376801f61330d8053c9393da813a3092f881634.tar.gz cpython-7376801f61330d8053c9393da813a3092f881634.tar.bz2 |
#8401: merge with 3.2.
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 8ce6c22..fe6e939 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -871,6 +871,24 @@ class ByteArrayTest(BaseBytesTest): b[3:0] = [42, 42, 42] self.assertEqual(b, bytearray([0, 1, 2, 42, 42, 42, 3, 4, 5, 6, 7, 8, 9])) + b[3:] = b'foo' + self.assertEqual(b, bytearray([0, 1, 2, 102, 111, 111])) + + b[:3] = memoryview(b'foo') + self.assertEqual(b, bytearray([102, 111, 111, 102, 111, 111])) + + b[3:4] = [] + self.assertEqual(b, bytearray([102, 111, 111, 111, 111])) + + for elem in [5, -5, 0, int(10e20), 'str', 2.3, + ['a', 'b'], [b'a', b'b'], [[]]]: + with self.assertRaises(TypeError): + b[3:4] = elem + + for elem in [[254, 255, 256], [-256, 9000]]: + with self.assertRaises(ValueError): + b[3:4] = elem + def test_extended_set_del_slice(self): indices = (0, None, 1, 3, 19, 300, 1<<333, -1, -2, -31, -300) for start in indices: |