Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7790297

Browse files
committed
test_support: add a docstring to vereq().
test_complex: repair new test's usage of vereq().
1 parent 5a0f010 commit 7790297

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Lib/test/test_complex.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def test_div(x, y):
6363
if complex(0.0, 0.0):
6464
raise TestFailed("complex(0.0, 0.0) should be false")
6565

66-
if vereq(complex(5.3, 9.8).conjugate(), 5.3-9.8j):
67-
raise TestFailed("complex.conjugate() didn't work")
66+
vereq(complex(5.3, 9.8).conjugate(), 5.3-9.8j)
6867

6968
try:
7069
print int(5+3j)

Lib/test/test_support.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ def verify(condition, reason='test failed'):
118118
raise TestFailed(reason)
119119

120120
def vereq(a, b):
121+
"""Raise TestFailed if a == b is false.
122+
123+
This is better than verify(a == b) because, in case of failure, the
124+
error message incorporates repr(a) and repr(b) so you can see the
125+
inputs.
126+
127+
Note that "not (a == b)" isn't necessarily the same as "a != b"; the
128+
former is tested.
129+
"""
130+
121131
if not (a == b):
122132
raise TestFailed, "%r == %r" % (a, b)
123133

0 commit comments

Comments
 (0)