summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-06-23 17:50:04 +0300
committerGitHub <noreply@github.com>2019-06-23 17:50:04 +0300
commit914d6b79735e5eabaf4e4d77e3f2ad4eae0beb9a (patch)
treeedc1ca4cf2ae7c7d5830b6ec52132b95904e0a0d
parent5c8b4e2b5de647a67dd1b6414fa520d2b8e973aa (diff)
downloadcpython-git-914d6b79735e5eabaf4e4d77e3f2ad4eae0beb9a.tar.gz
[3.8] bpo-35431: Test math.comb() and math.perm() for OverflowError only on CPython. (GH-14146) (#14226)
Other implementation can raise MemoryError, but it can takes hours. (cherry picked from commit 1b8a46d59734a77cd1f5ffcf3bdfcaafd58a87e7)
-rw-r--r--Lib/test/test_math.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index adefa07a40..b7dac5eeef 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -521,7 +521,7 @@ class MathTests(unittest.TestCase):
# Other implementations may place different upper bounds.
@support.cpython_only
def testFactorialHugeInputs(self):
- # Currently raises ValueError for inputs that are too large
+ # Currently raises OverflowError for inputs that are too large
# to fit into a C long.
self.assertRaises(OverflowError, math.factorial, 10**100)
self.assertRaises(OverflowError, math.factorial, 1e100)
@@ -1917,7 +1917,8 @@ class IsCloseTests(unittest.TestCase):
self.assertEqual(perm(n, 0), 1)
self.assertEqual(perm(n, 1), n)
self.assertEqual(perm(n, 2), n * (n-1))
- self.assertRaises((OverflowError, MemoryError), perm, n, n)
+ if support.check_impl_detail(cpython=True):
+ self.assertRaises(OverflowError, perm, n, n)
for n, k in (True, True), (True, False), (False, False):
self.assertEqual(perm(n, k), 1)
@@ -1986,7 +1987,8 @@ class IsCloseTests(unittest.TestCase):
self.assertEqual(comb(n, n), 1)
self.assertEqual(comb(n, n-1), n)
self.assertEqual(comb(n, n-2), n * (n-1) // 2)
- self.assertRaises((OverflowError, MemoryError), comb, n, n//2)
+ if support.check_impl_detail(cpython=True):
+ self.assertRaises(OverflowError, comb, n, n//2)
for n, k in (True, True), (True, False), (False, False):
self.assertEqual(comb(n, k), 1)