Skip to content

Commit 9649af5

Browse files
[3.13] gh-124040: Adjust few tests in testHypot/testDist to get exactly computed results (GH-124042) (#124235)
gh-124040: Adjust few tests in testHypot/testDist to get exactly computed results (GH-124042) (cherry picked from commit 4420cf4) Co-authored-by: Sergey B Kirpichev <[email protected]>
1 parent 9bae681 commit 9649af5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Lib/test/test_math.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,13 @@ def testHypot(self):
809809
# Test allowable types (those with __float__)
810810
self.assertEqual(hypot(12.0, 5.0), 13.0)
811811
self.assertEqual(hypot(12, 5), 13)
812-
self.assertEqual(hypot(1, -1), math.sqrt(2))
813-
self.assertEqual(hypot(1, FloatLike(-1.)), math.sqrt(2))
812+
self.assertEqual(hypot(0.75, -1), 1.25)
813+
self.assertEqual(hypot(-1, 0.75), 1.25)
814+
self.assertEqual(hypot(0.75, FloatLike(-1.)), 1.25)
815+
self.assertEqual(hypot(FloatLike(-1.), 0.75), 1.25)
814816
self.assertEqual(hypot(Decimal(12), Decimal(5)), 13)
815817
self.assertEqual(hypot(Fraction(12, 32), Fraction(5, 32)), Fraction(13, 32))
816-
self.assertEqual(hypot(bool(1), bool(0), bool(1), bool(1)), math.sqrt(3))
818+
self.assertEqual(hypot(True, False, True, True, True), 2.0)
817819

818820
# Test corner cases
819821
self.assertEqual(hypot(0.0, 0.0), 0.0) # Max input is zero
@@ -969,9 +971,9 @@ def testDist(self):
969971
self.assertEqual(dist((D(14), D(1)), (D(2), D(-4))), D(13))
970972
self.assertEqual(dist((F(14, 32), F(1, 32)), (F(2, 32), F(-4, 32))),
971973
F(13, 32))
972-
self.assertEqual(dist((True, True, False, True, False),
973-
(True, False, True, True, False)),
974-
sqrt(2.0))
974+
self.assertEqual(dist((True, True, False, False, True, True),
975+
(True, False, True, False, False, False)),
976+
2.0)
975977

976978
# Test corner cases
977979
self.assertEqual(dist((13.25, 12.5, -3.25),

0 commit comments

Comments
 (0)