Skip to content

Commit 1b8a46d

Browse files
bpo-35431: Test math.comb() and math.perm() for OverflowError only on CPython. (GH-14146)
Other implementation can raise MemoryError, but it can takes hours.
1 parent 231aad3 commit 1b8a46d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Lib/test/test_math.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def testFactorialNonIntegers(self):
525525
# Other implementations may place different upper bounds.
526526
@support.cpython_only
527527
def testFactorialHugeInputs(self):
528-
# Currently raises ValueError for inputs that are too large
528+
# Currently raises OverflowError for inputs that are too large
529529
# to fit into a C long.
530530
self.assertRaises(OverflowError, math.factorial, 10**100)
531531
with self.assertWarns(DeprecationWarning):
@@ -1922,7 +1922,8 @@ def testPerm(self):
19221922
self.assertEqual(perm(n, 0), 1)
19231923
self.assertEqual(perm(n, 1), n)
19241924
self.assertEqual(perm(n, 2), n * (n-1))
1925-
self.assertRaises((OverflowError, MemoryError), perm, n, n)
1925+
if support.check_impl_detail(cpython=True):
1926+
self.assertRaises(OverflowError, perm, n, n)
19261927

19271928
for n, k in (True, True), (True, False), (False, False):
19281929
self.assertEqual(perm(n, k), 1)
@@ -1991,7 +1992,8 @@ def testComb(self):
19911992
self.assertEqual(comb(n, n), 1)
19921993
self.assertEqual(comb(n, n-1), n)
19931994
self.assertEqual(comb(n, n-2), n * (n-1) // 2)
1994-
self.assertRaises((OverflowError, MemoryError), comb, n, n//2)
1995+
if support.check_impl_detail(cpython=True):
1996+
self.assertRaises(OverflowError, comb, n, n//2)
19951997

19961998
for n, k in (True, True), (True, False), (False, False):
19971999
self.assertEqual(comb(n, k), 1)

0 commit comments

Comments
 (0)