From 88a27b9c1e2e5607da8e1ad2b8ff3ec0e66e261d Mon Sep 17 00:00:00 2001 From: "Partha P. Mukherjee" Date: Sun, 5 Mar 2023 12:31:26 -0500 Subject: [PATCH] GH-102341: Improve the test function for pow (GH-102342) (cherry picked from commit 32220543e2db36c6146ff2704ed1714a6adecc1b) Co-authored-by: Partha P. Mukherjee Co-authored-by: Terry Jan Reedy --- Lib/test/test_pow.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py index 660ff80bbf522f..6395fb15ea06a7 100644 --- a/Lib/test/test_pow.py +++ b/Lib/test/test_pow.py @@ -19,12 +19,11 @@ def powtest(self, type): 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):