Skip to content

Commit 6d8dd17

Browse files
committed
test_math: Let "mtestfile" test 2-arg functions
1 parent d3254cd commit 6d8dd17

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Lib/test/test_math.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def parse_mtestfile(fname):
7979
-- starts a comment
8080
blank lines, or lines containing only a comment, are ignored
8181
other lines are expected to have the form
82-
id fn arg -> expected [flag]*
82+
id fn arg... -> expected [flag]*
8383
8484
"""
8585
with open(fname, encoding="utf-8") as fp:
@@ -91,12 +91,12 @@ def parse_mtestfile(fname):
9191
continue
9292

9393
lhs, rhs = line.split('->')
94-
id, fn, arg = lhs.split()
94+
id, fn, *args = lhs.split()
9595
rhs_pieces = rhs.split()
9696
exp = rhs_pieces[0]
9797
flags = rhs_pieces[1:]
9898

99-
yield (id, fn, float(arg), float(exp), flags)
99+
yield (id, fn, [float(arg) for arg in args], float(exp), flags)
100100

101101

102102
def parse_testfile(fname):
@@ -2285,10 +2285,10 @@ def test_testfile(self):
22852285

22862286
@requires_IEEE_754
22872287
def test_mtestfile(self):
2288-
fail_fmt = "{}: {}({!r}): {}"
2288+
fail_fmt = "{}: {}{!r}: {}"
22892289

22902290
failures = []
2291-
for id, fn, arg, expected, flags in parse_mtestfile(math_testcases):
2291+
for id, fn, args, expected, flags in parse_mtestfile(math_testcases):
22922292
func = getattr(math, fn)
22932293

22942294
if 'invalid' in flags or 'divide-by-zero' in flags:
@@ -2297,7 +2297,7 @@ def test_mtestfile(self):
22972297
expected = 'OverflowError'
22982298

22992299
try:
2300-
got = func(arg)
2300+
got = func(*args)
23012301
except ValueError:
23022302
got = 'ValueError'
23032303
except OverflowError:
@@ -2320,7 +2320,7 @@ def test_mtestfile(self):
23202320
# general.
23212321
abs_tol = 1e-15
23222322

2323-
elif fn == 'erfc' and arg >= 0.0:
2323+
elif fn == 'erfc' and (arg := args[0]) >= 0.0:
23242324
# erfc has less-than-ideal accuracy for large
23252325
# arguments (x ~ 25 or so), mainly due to the
23262326
# error involved in computing exp(-x*x).
@@ -2343,7 +2343,7 @@ def test_mtestfile(self):
23432343
if failure is None:
23442344
continue
23452345

2346-
msg = fail_fmt.format(id, fn, arg, failure)
2346+
msg = fail_fmt.format(id, fn, args, failure)
23472347
failures.append(msg)
23482348

23492349
if failures:

0 commit comments

Comments
 (0)