diff options
author | Eli Bendersky <eliben@gmail.com> | 2011-07-29 04:05:08 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2011-07-29 04:05:08 (GMT) |
commit | 906b88fb2a52725e78deeb8076a52671107e2af1 (patch) | |
tree | b3a9397d8e65a13d275731f7447088389c0a3526 /Lib/test/test_bytes.py | |
parent | 66d2be898611f32e3840025055f2cd9b92b9f19c (diff) | |
download | cpython-906b88fb2a52725e78deeb8076a52671107e2af1.zip cpython-906b88fb2a52725e78deeb8076a52671107e2af1.tar.gz cpython-906b88fb2a52725e78deeb8076a52671107e2af1.tar.bz2 |
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
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 234b56c..d32a44b 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -475,6 +475,27 @@ class BaseBytesTest(unittest.TestCase): 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))], |