[issue26257] Eliminate buffer_tests.py

Martin Panter report at bugs.python.org
Wed Apr 6 08:12:39 EDT 2016


Martin Panter added the comment:

I discovered a flaw in the bytearray tests: most of them don’t actually test bytearray objects! This is easy to fix in Python 3, and I added a test case to ensure that the arguments are converted to the expected type.

However porting this fix to Python 2 was trickier. A few of the bytearray methods do not accept bytearray arguments:

>>> bytearray(b"abc").ljust(10, bytearray(b"*"))
TypeError: ljust() argument 2 must be char, not bytearray
>>> bytearray(b"abc").rjust(10, bytearray(b"*"))
TypeError: rjust() argument 2 must be char, not bytearray
>>> bytearray(b"abc").center(10, bytearray(b"*"))
TypeError: center() argument 2 must be char, not bytearray

I adapted the tests from the deleted buffer_tests.py file to override the relevant tests from string_tests.py, so that we continue to test bytearray methods but with str a.k.a. bytes arguments.

----------
versions: +Python 2.7
Added file: http://bugs.python.org/file42377/buffer_tests.py2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26257>
_______________________________________


More information about the Python-bugs-list mailing list