Mailing List Archive

gh-109802: Add coverage test for complex_abs() (GH-117449)
https://github.com/python/cpython/commit/63bbe77d9bb2be4db83ed09b96dd22f2a44ef55b
commit: 63bbe77d9bb2be4db83ed09b96dd22f2a44ef55b
branch: main
author: Sergey B Kirpichev <skirpichev@gmail.com>
committer: encukou <encukou@gmail.com>
date: 2024-04-04T14:54:17Z
summary:

gh-109802: Add coverage test for complex_abs() (GH-117449)

* gh-109802: Add coverage test for complex_abs()

This tests overflow on L594.

// line numbers wrt to 0f2fa6150b

files:
M Lib/test/test_complex.py

diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index b057121f285dc7..fa3017b24e16c8 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -10,6 +10,7 @@

INF = float("inf")
NAN = float("nan")
+DBL_MAX = sys.float_info.max
# These tests ensure that complex math does the right thing

ZERO_DIVISION = (
@@ -597,6 +598,8 @@ def test_abs(self):
for num in nums:
self.assertAlmostEqual((num.real**2 + num.imag**2) ** 0.5, abs(num))

+ self.assertRaises(OverflowError, abs, complex(DBL_MAX, DBL_MAX))
+
def test_repr_str(self):
def test(v, expected, test_fn=self.assertEqual):
test_fn(repr(v), expected)

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-leave@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: list-python-checkins@lists.gossamer-threads.com