summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
authorAmmar Askar <ammar@ammaraskar.com>2019-09-21 04:28:49 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-21 04:28:49 (GMT)
commit87d6cd3604e5c83c06339276228139f5e040b0e7 (patch)
tree8625c8ec9abe6f81b425b742d9a8e0ab2785e4e3 /Lib/test/test_builtin.py
parente267793aa4101b2771ed0e66aaff5743d23f59af (diff)
downloadcpython-87d6cd3604e5c83c06339276228139f5e040b0e7.zip
cpython-87d6cd3604e5c83c06339276228139f5e040b0e7.tar.gz
cpython-87d6cd3604e5c83c06339276228139f5e040b0e7.tar.bz2
bpo-38237: Make pow's arguments have more descriptive names and be keyword passable (GH-16302)
Edit: `math.pow` changes removed on Mark's request. https://bugs.python.org/issue38237 Automerge-Triggered-By: @rhettinger
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index e1d2fff..abccf32 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -19,6 +19,7 @@ import types
import unittest
import warnings
from contextlib import ExitStack
+from functools import partial
from inspect import CO_COROUTINE
from itertools import product
from textwrap import dedent
@@ -1206,6 +1207,18 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, pow)
+ # Test passing in arguments as keywords.
+ self.assertEqual(pow(0, exp=0), 1)
+ self.assertEqual(pow(base=2, exp=4), 16)
+ self.assertEqual(pow(base=5, exp=2, mod=14), 11)
+ twopow = partial(pow, base=2)
+ self.assertEqual(twopow(exp=5), 32)
+ fifth_power = partial(pow, exp=5)
+ self.assertEqual(fifth_power(2), 32)
+ mod10 = partial(pow, mod=10)
+ self.assertEqual(mod10(2, 6), 4)
+ self.assertEqual(mod10(exp=6, base=2), 4)
+
def test_input(self):
self.write_testfile()
fp = open(TESTFN, 'r')