summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2018-09-03 21:20:06 (GMT)
committerGitHub <noreply@github.com>2018-09-03 21:20:06 (GMT)
commite9ba3705de656215d52b8f8f4a2e7ad60190e944 (patch)
treefd2e22464103a3a36efd27788e02c697b199b43a /Lib/test/test_math.py
parent65fc98e7b1f62c2e621f04780a3a77c3498cc195 (diff)
downloadcpython-e9ba3705de656215d52b8f8f4a2e7ad60190e944.zip
cpython-e9ba3705de656215d52b8f8f4a2e7ad60190e944.tar.gz
cpython-e9ba3705de656215d52b8f8f4a2e7ad60190e944.tar.bz2
bpo-33083 - Make math.factorial reject arguments that are not int-like (GH-6149)
math.factorial() was accepting non-integral Decimal instances. This is inconsistent with the actual behaviour for floats, which are not accepted.
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index fff82fe..608789f 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -5,6 +5,7 @@ from test.support import run_unittest, verbose, requires_IEEE_754
from test import support
import unittest
import itertools
+import decimal
import math
import os
import platform
@@ -510,6 +511,10 @@ class MathTests(unittest.TestCase):
self.assertRaises(ValueError, math.factorial, -1e100)
self.assertRaises(ValueError, math.factorial, math.pi)
+ def testFactorialNonIntegers(self):
+ self.assertRaises(TypeError, math.factorial, decimal.Decimal(5.2))
+ self.assertRaises(TypeError, math.factorial, "5")
+
# Other implementations may place different upper bounds.
@support.cpython_only
def testFactorialHugeInputs(self):