diff --git a/py/magic/exprinfo.py b/py/magic/exprinfo.py index a30033955..77785a56e 100644 --- a/py/magic/exprinfo.py +++ b/py/magic/exprinfo.py @@ -428,7 +428,9 @@ def interpret(source, frame, should_fail=False): import traceback traceback.print_exc() 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: return None diff --git a/py/magic/testing/test_exprinfo.py b/py/magic/testing/test_exprinfo.py index 12a69272d..517df1561 100644 --- a/py/magic/testing/test_exprinfo.py +++ b/py/magic/testing/test_exprinfo.py @@ -119,3 +119,15 @@ def test_keyboard_interrupt(): pass else: 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") +