Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertSequenceEqual() raises BytesWarning when format message #71024

Closed
serhiy-storchaka opened this issue Apr 24, 2016 · 4 comments
Closed

assertSequenceEqual() raises BytesWarning when format message #71024

serhiy-storchaka opened this issue Apr 24, 2016 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 26837
Nosy @rbtcollins, @ezio-melotti, @voidspace, @vadmium, @serhiy-storchaka
Files
  • unittest_assert_bytes_warning.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-04-25.06:01:04.513>
    created_at = <Date 2016-04-24.15:32:26.204>
    labels = ['tests', 'type-bug', 'library']
    title = 'assertSequenceEqual() raises BytesWarning when format message'
    updated_at = <Date 2016-04-25.06:01:04.511>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-04-25.06:01:04.511>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-04-25.06:01:04.513>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2016-04-24.15:32:26.204>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['42581']
    hgrepos = []
    issue_num = 26837
    keywords = ['patch']
    message_count = 4.0
    messages = ['264110', '264137', '264154', '264155']
    nosy_count = 6.0
    nosy_names = ['rbcollins', 'ezio.melotti', 'michael.foord', 'python-dev', 'martin.panter', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26837'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Apr 24, 2016
    @vadmium
    Copy link
    Member

    vadmium commented Apr 25, 2016

    I think the change is good in spirit, especially using repr() and limiting the size. See the review for a couple problems.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 25, 2016

    New changeset ae5cc8ab664a by Serhiy Storchaka in branch '3.5':
    Issue bpo-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 bpo-26837: assertSequenceEqual() now correctly outputs non-stringified
    https://hg.python.org/cpython/rev/d0d541c2afb7

    @serhiy-storchaka
    Copy link
    Member Author

    Thank you for your helpful review Martin!

    @serhiy-storchaka serhiy-storchaka self-assigned this Apr 25, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants