Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_bytes.py @ 50328:7a011680e151
#4759: allow None as first argument of bytearray.translate(), for consistency with bytes.translate().
Also fix segfault for bytearray.translate(x, None) -- will backport this part to 3.0 and 2.6.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 28 Dec 2008 11:44:14 +0000 |
| parents | 1693fd94d829 |
| children | 4407e4d07084 |
line wrap: on
line diff
--- a/Lib/test/test_bytes.py Sun Dec 28 02:13:22 2008 +0000 +++ b/Lib/test/test_bytes.py Sun Dec 28 11:44:14 2008 +0000 @@ -888,11 +888,21 @@ def test_translate(self): b = b'hello' + ba = bytearray(b) rosetta = bytearray(range(0, 256)) rosetta[ord('o')] = ord('e') c = b.translate(rosetta, b'l') self.assertEqual(b, b'hello') self.assertEqual(c, b'hee') + c = ba.translate(rosetta, b'l') + self.assertEqual(ba, b'hello') + self.assertEqual(c, b'hee') + c = b.translate(None, b'e') + self.assertEqual(c, b'hllo') + c = ba.translate(None, b'e') + self.assertEqual(c, b'hllo') + self.assertRaises(TypeError, b.translate, None, None) + self.assertRaises(TypeError, ba.translate, None, None) def test_split_bytearray(self): self.assertEqual(b'a b'.split(memoryview(b' ')), [b'a', b'b'])
