From: Serhiy Storchaka Date: Tue, 18 Feb 2025 08:18:40 +0000 (+0200) Subject: [3.12] gh-130230: Add new tests for 3-arg pow() with Decimal (GH-130237) (GH-130247) X-Git-Tag: v3.12.10~202 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a6415cbacf72d782002f49cde9fccfd5b3f92c4;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-130230: Add new tests for 3-arg pow() with Decimal (GH-130237) (GH-130247) (cherry picked from commit b93b7e566e5a4efe7f077af2083140e50bd2b08f) --- diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 2ec12439d7fe..dc1c431a7649 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -4463,6 +4463,15 @@ class Coverage: self.assertIs(Decimal("NaN").fma(7, 1).is_nan(), True) # three arg power self.assertEqual(pow(Decimal(10), 2, 7), 2) + if self.decimal == C: + self.assertEqual(pow(10, Decimal(2), 7), 2) + self.assertEqual(pow(10, 2, Decimal(7)), 2) + else: + # XXX: Three-arg power doesn't use __rpow__. + self.assertRaises(TypeError, pow, 10, Decimal(2), 7) + # XXX: There is no special method to dispatch on the + # third arg of three-arg power. + self.assertRaises(TypeError, pow, 10, 2, Decimal(7)) # exp self.assertEqual(Decimal("1.01").exp(), 3) # is_normal