improve assert re-inteprpretation for comparisons

--HG--
branch : 1.0.x
This commit is contained in:
holger krekel
2009-07-26 15:31:23 +02:00
parent 9aa781907e
commit 5b205e0711
3 changed files with 30 additions and 2 deletions
+23
View File
@@ -131,3 +131,26 @@ def test_inconsistent_assert_result(testdir):
s = result.stdout.str()
assert s.find("re-run") != -1
def test_twoarg_comparison_does_not_call_nonzero():
# this arises e.g. in numpy array comparisons
class X(object):
def __eq__(self, other):
return self
def __nonzero__(self):
raise ValueError
def all(self):
return False
def f():
a = X()
b = X()
assert (a == b).all()
excinfo = getexcinfo(AssertionError, f)
msg = getmsg(excinfo)
print msg
assert "re-run" not in msg
assert "ValueError" not in msg