refine error message for inconsistently failing asserts
--HG-- branch : trunk
This commit is contained in:
parent
84f2d332ce
commit
975e681552
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue