Captured stdout printed twice

Create issue
Issue #134 invalid
Former user created an issue

The following test prints the captured stdout twice:

{{{ def render(**variables): print "Checking {}".format(variables) return variables

def with_all_versions(func): def decorated(): yield func, render return decorated

@with_all_versions def test_text(r): assert "y" in r(x=u'gurk')


The output I get is the following: {{{ ==== test session starts === platform darwin -- Python 2.7.0 -- pytest-1.3.4 test path 1: F

========= FAILURES ========= _ test_text[0] _

r = <function render at 0x101dfecf8>

def test_text(r):
  assert "y" in  r(x=u'gurk')

E assert 'y' in {'x': u'gurk'} E + where {'x': u'gurk'} = <function render at 0x101dfecf8>(x=u'gurk') AssertionError ------ Captured stdout ----- Checking {'x': u'gurk'} Checking {'x': u'gurk'} = 1 failed in 0.07 seconds = }}}

I would have expected the output

{{{ Checking {'x': u'gurk'} }}}

only once.

Comments (4)

  1. Holger Krekel repo owner

    It's a known issue: when an assertion fails the expression of the assertion is re-run to print intermediate values. This means in your case that the function call is repeated, thus the double print. We have a plan to avoid the re-interpretation but it requires some more experimentation and work.

    best, holger

  2. Former user Account Deleted

    Re-interpretation shouldn't be a problem as long as the captured output is thrown away the second time.

  3. Log in to comment