Skip to content

update test_cmath.py from cpython 3.11.2 #4758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Lib/test/test_cmath.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from test.support import requires_IEEE_754, cpython_only
from test.support import requires_IEEE_754, cpython_only, import_helper
from test.test_math import parse_testfile, test_file
import test.test_math as test_math
import unittest
Expand Down Expand Up @@ -60,7 +60,7 @@ class CMathTests(unittest.TestCase):
test_functions.append(lambda x : cmath.log(14.-27j, x))

def setUp(self):
self.test_values = open(test_file)
self.test_values = open(test_file, encoding="utf-8")

def tearDown(self):
self.test_values.close()
Expand Down Expand Up @@ -460,13 +460,13 @@ def test_polar(self):
@cpython_only
def test_polar_errno(self):
# Issue #24489: check a previously set C errno doesn't disturb polar()
from _testcapi import set_errno
_testcapi = import_helper.import_module('_testcapi')
def polar_with_errno_set(z):
set_errno(11)
_testcapi.set_errno(11)
try:
return polar(z)
finally:
set_errno(0)
_testcapi.set_errno(0)
self.check_polar(polar_with_errno_set)

def test_phase(self):
Expand Down Expand Up @@ -534,6 +534,7 @@ def test_abs(self):
self.assertEqual(abs(complex(INF, NAN)), INF)
self.assertTrue(math.isnan(abs(complex(NAN, NAN))))


@requires_IEEE_754
def test_abs_overflows(self):
# result overflows
Expand Down