Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_bytes.py @ 71543:536fccc75f5a
Issue #12380: PyArg_ParseTuple now accepts a bytearray for the 'c' format.
As a side effect, this now allows the rjust, ljust and center methods of
bytes and bytearray to accept a bytearray argument.
Patch by Petri Lehtinen
| author | Eli Bendersky <eliben@gmail.com> |
|---|---|
| date | Fri, 29 Jul 2011 07:05:08 +0300 |
| parents | a1a1296556d7 |
| children | c1effa2cdd20 |
line wrap: on
line diff
--- a/Lib/test/test_bytes.py Thu Jul 28 09:55:13 2011 -0700 +++ b/Lib/test/test_bytes.py Fri Jul 29 07:05:08 2011 +0300 @@ -475,6 +475,27 @@ self.assertRaises(TypeError, self.type2test(b'abc').lstrip, 'b') self.assertRaises(TypeError, self.type2test(b'abc').rstrip, 'b') + def test_center(self): + # Fill character can be either bytes or bytearray (issue 12380) + b = self.type2test(b'abc') + for fill_type in (bytes, bytearray): + self.assertEqual(b.center(7, fill_type(b'-')), + self.type2test(b'--abc--')) + + def test_ljust(self): + # Fill character can be either bytes or bytearray (issue 12380) + b = self.type2test(b'abc') + for fill_type in (bytes, bytearray): + self.assertEqual(b.ljust(7, fill_type(b'-')), + self.type2test(b'abc----')) + + def test_rjust(self): + # Fill character can be either bytes or bytearray (issue 12380) + b = self.type2test(b'abc') + for fill_type in (bytes, bytearray): + self.assertEqual(b.rjust(7, fill_type(b'-')), + self.type2test(b'----abc')) + def test_ord(self): b = self.type2test(b'\0A\x7f\x80\xff') self.assertEqual([ord(b[i:i+1]) for i in range(len(b))],
