From 77902970c598c068a2916e86ca386d1387c4c369 Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Sat, 29 Dec 2001 17:34:57 +0000 Subject: test_support: add a docstring to vereq(). test_complex: repair new test's usage of vereq(). --- Lib/test/test_complex.py | 3 +-- Lib/test/test_support.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index 1fa0ee0..ff7bb14 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -63,8 +63,7 @@ for i in range(100): if complex(0.0, 0.0): raise TestFailed("complex(0.0, 0.0) should be false") -if vereq(complex(5.3, 9.8).conjugate(), 5.3-9.8j): - raise TestFailed("complex.conjugate() didn't work") +vereq(complex(5.3, 9.8).conjugate(), 5.3-9.8j) try: print int(5+3j) diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 83bde3e..4a45617 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -118,6 +118,16 @@ def verify(condition, reason='test failed'): raise TestFailed(reason) def vereq(a, b): + """Raise TestFailed if a == b is false. + + This is better than verify(a == b) because, in case of failure, the + error message incorporates repr(a) and repr(b) so you can see the + inputs. + + Note that "not (a == b)" isn't necessarily the same as "a != b"; the + former is tested. + """ + if not (a == b): raise TestFailed, "%r == %r" % (a, b) -- cgit v0.12