summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-03-05 17:53:50 (GMT)
committerGitHub <noreply@github.com>2023-03-05 17:53:50 (GMT)
commit9cec6022e438a28a66bc775b497f97d8bbad9610 (patch)
tree0246172c2d01ef1faa37fb0a264b7c073e98d8df
parent94e08e174d8828298e51501e505ab567cd80ef25 (diff)
downloadcpython-9cec6022e438a28a66bc775b497f97d8bbad9610.zip
cpython-9cec6022e438a28a66bc775b497f97d8bbad9610.tar.gz
cpython-9cec6022e438a28a66bc775b497f97d8bbad9610.tar.bz2
GH-102341: Improve the test function for pow (GH-102342)
(cherry picked from commit 32220543e2db36c6146ff2704ed1714a6adecc1b) Co-authored-by: Partha P. Mukherjee <ppm.floss@gmail.com> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
-rw-r--r--Lib/test/test_pow.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py
index 660ff80..6395fb1 100644
--- a/Lib/test/test_pow.py
+++ b/Lib/test/test_pow.py
@@ -19,12 +19,11 @@ class PowTest(unittest.TestCase):
self.assertEqual(pow(2, i), pow2)
if i != 30 : pow2 = pow2*2
- for othertype in (int,):
- for i in list(range(-10, 0)) + list(range(1, 10)):
- ii = type(i)
- for j in range(1, 11):
- jj = -othertype(j)
- pow(ii, jj)
+ for i in list(range(-10, 0)) + list(range(1, 10)):
+ ii = type(i)
+ inv = pow(ii, -1) # inverse of ii
+ for jj in range(-10, 0):
+ self.assertAlmostEqual(pow(ii, jj), pow(inv, -jj))
for othertype in int, float:
for i in range(1, 100):