Skip to content

assert reinterpretation fails for some code layouts #1

Closed

Description

@pytestbot

Originally reported by: Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt)


the code example is

#!python

def test_assert():
    result = None
    assert result == [
        (None, [ 'some text\n', 'more text\n']),
    ]

the given output is

$ py.test test_assert.py 
============================= test session starts ==============================
platform linux2 -- Python 2.6.6 -- pytest-2.0.0dev0
test path 1: test_assert.py

test_assert.py F

=================================== FAILURES ===================================
_________________________________ test_assert __________________________________

    def test_assert():
        result = None
        assert result == [
>           (None, [ 'some text\n', 'more text\n']),
E           AssertionError: (assertion failed, but when it was re-run for printing intermediate values, it did not fail.  Suggestions: compute assert expression before the assert or use --no-assert)

test_assert.py:5: AssertionError
=========================== 1 failed in 0.20 seconds ===========================

Activity

  1. pytestbot commented on Oct 10, 2010

    @pytestbot
    ContributorAuthor

    Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


    note

    • this works fine with the old assertion code (thats used on python without ast)
    • putting the list into a variable and using that in the assertion works as well
  2. pytestbot commented on Nov 23, 2010

    @pytestbot
    ContributorAuthor

    Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


    think this is fixed now in py-1.4.0.dev3 with an improved heuristic (and don't think this used to work for the old assertion code but maybe i am missing something).

  3. added a commit that references this issue on Jun 25, 2016
  4. added 2 commits that reference this issue on Nov 11, 2016
    84d7068
    26b1519
  5. added a commit that references this issue on Feb 21, 2019
  6. added a commit that references this issue on Dec 12, 2019
  7. added a commit that references this issue on Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions