summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-08 16:17:33 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2019-06-08 16:17:33 (GMT)
commitfeaceaafe816e95c4aff15eab0bea6dc2bbfe4fd (patch)
tree1809f17e0075595a64c31ff9ee19cb1b5c605a15 /Lib/test/test_math.py
parent6324ac1293b2cf71559869b88f89f510f9a62a8e (diff)
downloadcpython-feaceaafe816e95c4aff15eab0bea6dc2bbfe4fd.zip
cpython-feaceaafe816e95c4aff15eab0bea6dc2bbfe4fd.tar.gz
cpython-feaceaafe816e95c4aff15eab0bea6dc2bbfe4fd.tar.bz2
bpo-37178: Allow a one argument form of math.perm() (GH-13905) (GH-13919)
(cherry picked from commit e119b3d136bd94d880bce4b382096f6de3f38062) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 86e3923..adefa07 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -1885,8 +1885,13 @@ class IsCloseTests(unittest.TestCase):
self.assertEqual(perm(n, 1), n)
self.assertEqual(perm(n, n), factorial(n))
+ # Test one argument form
+ for n in range(20):
+ self.assertEqual(perm(n), factorial(n))
+ self.assertEqual(perm(n, None), factorial(n))
+
# Raises TypeError if any argument is non-integer or argument count is
- # not 2
+ # not 1 or 2
self.assertRaises(TypeError, perm, 10, 1.0)
self.assertRaises(TypeError, perm, 10, decimal.Decimal(1.0))
self.assertRaises(TypeError, perm, 10, "1")
@@ -1894,7 +1899,7 @@ class IsCloseTests(unittest.TestCase):
self.assertRaises(TypeError, perm, decimal.Decimal(10.0), 1)
self.assertRaises(TypeError, perm, "10", 1)
- self.assertRaises(TypeError, perm, 10)
+ self.assertRaises(TypeError, perm)
self.assertRaises(TypeError, perm, 10, 1, 3)
self.assertRaises(TypeError, perm)