This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bytearray needs more tests for "b.some_method()[0] is not b"
Type: Stage: needs patch
Components: Interpreter Core, Tests Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, flox, pitrou
Priority: normal Keywords: patch

Created on 2010-01-03 20:04 by flox, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7625_tests.diff flox, 2010-01-04 08:01 Patch, apply to trunk
Messages (4)
msg97176 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-03 20:04
There's not enough tests to verify such cases:
 - b.split()[0] is not b
 - b.rsplit()[0] is not b
 - b.splitlines()[0] is not b
 - b.partition('.')[0] is not b
 - b.rpartition('.')[0] is not b
 - (other ?)

However similar tests exist in Lib/test/test_bytes:
 * ByteArrayTest.test_copied()
   -> some tests for ('replace', 'translate')
 * ByteArrayTest.test_partition_bytearray_doesnt_share_nullstring
   -> some tests for ('partition', 'rpartition')
 * BytearrayPEP3137Test.test_returns_new_copy()
   -> some tests for ('zfill', 'rjust', 'ljust', 'center')
msg97178 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-03 20:28
And each test comes with a new bug :)

>>> x = bytearray('abc')
>>> x.partition('.')[0] is x
True
>>> x.rpartition('.')[2] is x
True
msg97195 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-04 08:01
Patch for some additional test cases attached.

The bug "b.partition('.')[0] is b" is fixed with the patch proposed on issue7622.
msg97723 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-13 15:04
Committed in trunk (r77475) and py3k (r77476).
Thank you.
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51874
2010-01-13 15:04:01pitrousetstatus: open -> closed
versions: - Python 2.6, Python 3.1
nosy: + pitrou

messages: + msg97723

resolution: fixed
2010-01-04 08:01:27floxsetfiles: + issue7625_tests.diff
keywords: + patch
messages: + msg97195
2010-01-03 21:47:39ezio.melottisetnosy: + ezio.melotti
2010-01-03 20:36:37floxsetcomponents: + Interpreter Core
versions: + Python 2.6, Python 3.1, Python 3.2
2010-01-03 20:28:46floxsetpriority: low -> normal

messages: + msg97178
2010-01-03 20:04:27floxcreate