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: assertSequenceEqual() raises BytesWarning when format message
Type: behavior Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: ezio.melotti, martin.panter, michael.foord, python-dev, rbcollins, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-04-24 15:32 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unittest_assert_bytes_warning.patch serhiy.storchaka, 2016-04-24 15:32 review
Messages (4)
msg264110 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-04-24 15:32
assertSequenceEqual() raises BytesWarning when format failure report. See for example http://buildbot.python.org/all/builders/AMD64%20OpenIndiana%203.x/builds/10575/steps/test/logs/stdio :

======================================================================
ERROR: test_close_fds_0_1 (test.test_subprocess.POSIXProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_subprocess.py", line 1741, in test_close_fds_0_1
    self.check_close_std_fds([0, 1])
  File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_subprocess.py", line 1727, in check_close_std_fds
    self.assertEqual((out, err), (b'apple', b'orange'))
  File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/unittest/case.py", line 820, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/unittest/case.py", line 1029, in assertTupleEqual
    self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
  File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/unittest/case.py", line 967, in assertSequenceEqual
    (i, item1, item2))
BytesWarning: str() on a bytes instance

======================================================================

Proposed patch fixes message formatting and adds tests for assertions that can emit BytesWarning.
msg264137 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-04-25 00:44
I think the change is good in spirit, especially using repr() and limiting the size. See the review for a couple problems.
msg264154 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-25 06:00
New changeset ae5cc8ab664a by Serhiy Storchaka in branch '3.5':
Issue #26837: assertSequenceEqual() now correctly outputs non-stringified
https://hg.python.org/cpython/rev/ae5cc8ab664a

New changeset d0d541c2afb7 by Serhiy Storchaka in branch '2.7':
Issue #26837: assertSequenceEqual() now correctly outputs non-stringified
https://hg.python.org/cpython/rev/d0d541c2afb7
msg264155 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-04-25 06:01
Thank you for your helpful review Martin!
History
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71024
2016-06-23 19:38:10skrahlinkissue27375 superseder
2016-04-25 06:01:04serhiy.storchakasetstatus: open -> closed
messages: + msg264155

assignee: serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2016-04-25 06:00:21python-devsetnosy: + python-dev
messages: + msg264154
2016-04-25 00:44:57martin.pantersetnosy: + martin.panter

messages: + msg264137
stage: patch review
2016-04-24 15:32:26serhiy.storchakacreate