refine error message for inconsistently failing asserts

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-04-28 12:10:56 +02:00
parent 84f2d332ce
commit 975e681552
2 changed files with 15 additions and 1 deletions

View File

@ -428,7 +428,9 @@ def interpret(source, frame, should_fail=False):
import traceback import traceback
traceback.print_exc() traceback.print_exc()
if should_fail: if should_fail:
return "(inconsistently failed then succeeded)" return ("(assert failed but re-evaluating the assert expression "
"for printing intermediate values lead to a True value. "
"advise: avoid side-effects in assert expressions or use --nomagic)")
else: else:
return None return None

View File

@ -119,3 +119,15 @@ def test_keyboard_interrupt():
pass pass
else: else:
raise AssertionError, "ex %s didn't pass through" %(exstr, ) raise AssertionError, "ex %s didn't pass through" %(exstr, )
def test_inconsistent_assert_result(testdir):
p = testdir.makepyfile("""
def test_func():
def f(l=[1,0]):
return l.pop()
assert f()
""")
result = testdir.runpytest(p)
s = result.stdout.str()
assert s.find("re-evaluating")