summaryrefslogtreecommitdiff
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2015-01-23 20:05:18 -0800
committerEthan Furman <ethan@stoneleaf.us>2015-01-23 20:05:18 -0800
commitb95b56150fc3e7834783b54acdddeaed4fe44e27 (patch)
treec1994946e84b457841024402b50f8a9640211cb4 /Lib/test/test_bytes.py
parent8861502e0746465c4124548681f05969c08f4cae (diff)
downloadcpython-git-b95b56150fc3e7834783b54acdddeaed4fe44e27.tar.gz
Issue20284: Implement PEP461
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index e8dde5df76..995a908718 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -461,6 +461,28 @@ class BaseBytesTest:
self.assertEqual(b.rindex(i, 3, 9), 7)
self.assertRaises(ValueError, b.rindex, w, 1, 3)
+ def test_mod(self):
+ b = b'hello, %b!'
+ orig = b
+ b = b % b'world'
+ self.assertEqual(b, b'hello, world!')
+ self.assertEqual(orig, b'hello, %b!')
+ self.assertFalse(b is orig)
+ b = b'%s / 100 = %d%%'
+ a = b % (b'seventy-nine', 79)
+ self.assertEquals(a, b'seventy-nine / 100 = 79%')
+
+ def test_imod(self):
+ b = b'hello, %b!'
+ orig = b
+ b %= b'world'
+ self.assertEqual(b, b'hello, world!')
+ self.assertEqual(orig, b'hello, %b!')
+ self.assertFalse(b is orig)
+ b = b'%s / 100 = %d%%'
+ b %= (b'seventy-nine', 79)
+ self.assertEquals(b, b'seventy-nine / 100 = 79%')
+
def test_replace(self):
b = self.type2test(b'mississippi')
self.assertEqual(b.replace(b'i', b'a'), b'massassappa')
@@ -990,6 +1012,28 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
b[8:] = b
self.assertEqual(b, bytearray(list(range(8)) + list(range(256))))
+ def test_mod(self):
+ b = bytearray(b'hello, %b!')
+ orig = b
+ b = b % b'world'
+ self.assertEqual(b, b'hello, world!')
+ self.assertEqual(orig, bytearray(b'hello, %b!'))
+ self.assertFalse(b is orig)
+ b = bytearray(b'%s / 100 = %d%%')
+ a = b % (b'seventy-nine', 79)
+ self.assertEquals(a, bytearray(b'seventy-nine / 100 = 79%'))
+
+ def test_imod(self):
+ b = bytearray(b'hello, %b!')
+ orig = b
+ b %= b'world'
+ self.assertEqual(b, b'hello, world!')
+ self.assertEqual(orig, bytearray(b'hello, %b!'))
+ self.assertFalse(b is orig)
+ b = bytearray(b'%s / 100 = %d%%')
+ b %= (b'seventy-nine', 79)
+ self.assertEquals(b, bytearray(b'seventy-nine / 100 = 79%'))
+
def test_iconcat(self):
b = bytearray(b"abc")
b1 = b