diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index 1730fdf054..8abbda2d87 100644 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -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 @@ -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() @@ -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): @@ -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