summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-04-15 14:11:10 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-04-15 14:11:10 +0300
commit6fc4e9c8e178eef8e0d4607b062b056e075611c0 (patch)
tree7584d25b795418d2870a2745ca6a43c879931084 /Lib
parent2bde55ad3c25edcb6265893a8c8eee203a6a179b (diff)
downloadcpython-6fc4e9c8e178eef8e0d4607b062b056e075611c0.tar.gz
Issue #26764: Fixed SystemError in bytes.__rmod__.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bytes.py37
1 files changed, 11 insertions, 26 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index bd3410f7e4..966e287afe 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -483,26 +483,33 @@ class BaseBytesTest:
self.assertRaises(ValueError, b.rindex, w, 1, 3)
def test_mod(self):
- b = b'hello, %b!'
+ b = self.type2test(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%%'
+ b = self.type2test(b'%s / 100 = %d%%')
a = b % (b'seventy-nine', 79)
self.assertEqual(a, b'seventy-nine / 100 = 79%')
+ self.assertIs(type(a), bytes)
def test_imod(self):
- b = b'hello, %b!'
+ b = self.type2test(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 = self.type2test(b'%s / 100 = %d%%')
b %= (b'seventy-nine', 79)
self.assertEqual(b, b'seventy-nine / 100 = 79%')
+ self.assertIs(type(b), bytes)
+
+ def test_rmod(self):
+ with self.assertRaises(TypeError):
+ object() % self.type2test(b'abc')
+ self.assertIs(self.type2test(b'abc').__rmod__('%r'), NotImplemented)
def test_replace(self):
b = self.type2test(b'mississippi')
@@ -1064,28 +1071,6 @@ 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.assertEqual(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.assertEqual(b, bytearray(b'seventy-nine / 100 = 79%'))
-
def test_iconcat(self):
b = bytearray(b"abc")
b1 = b