summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-11-19 22:05:53 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-11-19 22:05:53 (GMT)
commit866eba940f1ff9cf2ddf10dacb39e3721e2d6a9a (patch)
tree9c25d4fe6aa5a1fbd092dea867ceff0bb5d7046f /Lib/test
parent6df732777c682c5cdf74cd3b1b9d2be151f544ca (diff)
downloadcpython-866eba940f1ff9cf2ddf10dacb39e3721e2d6a9a.zip
cpython-866eba940f1ff9cf2ddf10dacb39e3721e2d6a9a.tar.gz
cpython-866eba940f1ff9cf2ddf10dacb39e3721e2d6a9a.tar.bz2
Merged revisions 67291 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67291 | benjamin.peterson | 2008-11-19 15:49:09 -0600 (Wed, 19 Nov 2008) | 5 lines make sure that bytearray methods return a new bytearray even if there is no change Fixes #4348 Reviewed by Brett ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_bytes.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index a583a48..6e5ffa9 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -721,6 +721,16 @@ class ByteArrayTest(BaseBytesTest):
b.insert(0, Indexable(ord('A')))
self.assertEqual(b, b'A')
+ def test_copied(self):
+ # Issue 4348. Make sure that operations that don't mutate the array
+ # copy the bytes.
+ b = bytearray(b'abc')
+ #self.assertFalse(b is b.replace(b'abc', b'cde', 0))
+
+ t = bytearray([i for i in range(256)])
+ x = bytearray(b'')
+ self.assertFalse(x is x.translate(t))
+
def test_partition_bytearray_doesnt_share_nullstring(self):
a, b, c = bytearray(b"x").partition(b"y")
self.assertEqual(b, b"")