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

assert reinterpretation fails for some code layouts #1

Closed
pytestbot opened this issue Oct 10, 2010 · 2 comments
Closed

assert reinterpretation fails for some code layouts #1

pytestbot opened this issue Oct 10, 2010 · 2 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

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 ===========================

@pytestbot
Copy link
Contributor Author

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

@pytestbot
Copy link
Contributor Author

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).

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
hpk42 pushed a commit that referenced this issue Jun 25, 2016
Factor setuponly code out of runtestprotocol().
nicoddemus added a commit that referenced this issue Nov 11, 2016
nicoddemus pushed a commit that referenced this issue Feb 21, 2019
update links for virtualenv -> venv
nicoddemus pushed a commit that referenced this issue Dec 12, 2019
Zac-HD pushed a commit that referenced this issue Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant