summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-21 08:22:29 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2019-09-21 08:22:29 (GMT)
commit37bc93552375cb1bc616927b5c1905bae3c0e99d (patch)
treeae8f115f589df2e475117329dcaec70591b1b023 /Lib
parent865bb685a67798eb98dcf5f3a852e08c77792998 (diff)
downloadcpython-37bc93552375cb1bc616927b5c1905bae3c0e99d.zip
cpython-37bc93552375cb1bc616927b5c1905bae3c0e99d.tar.gz
cpython-37bc93552375cb1bc616927b5c1905bae3c0e99d.tar.bz2
bpo-38237: Let pow() support keyword arguments (GH-16302) (GH-16320)
Backported with release manager approval
Diffstat (limited to 'Lib')
-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 9baac3c..cc20551 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')