gh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014)

Split complex.c tests of _testcapi into two parts: limited C API
tests in _testlimitedcapi and non-limited C API tests in _testcapi.
This commit is contained in:
Victor Stinner 2024-03-19 17:23:12 +01:00 committed by GitHub
parent 7f64ae30dd
commit 61c659e2dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 92 additions and 67 deletions

View file

@ -10,6 +10,7 @@
_testcapi = import_helper.import_module('_testcapi')
_testlimitedcapi = import_helper.import_module('_testlimitedcapi')
NULL = None
INF = float("inf")
@ -25,7 +26,7 @@ def __complex__(self):
class CAPIComplexTest(unittest.TestCase):
def test_check(self):
# Test PyComplex_Check()
check = _testcapi.complex_check
check = _testlimitedcapi.complex_check
self.assertTrue(check(1+2j))
self.assertTrue(check(ComplexSubclass(1+2j)))
@ -38,7 +39,7 @@ def test_check(self):
def test_checkexact(self):
# PyComplex_CheckExact()
checkexact = _testcapi.complex_checkexact
checkexact = _testlimitedcapi.complex_checkexact
self.assertTrue(checkexact(1+2j))
self.assertFalse(checkexact(ComplexSubclass(1+2j)))
@ -57,13 +58,13 @@ def test_fromccomplex(self):
def test_fromdoubles(self):
# Test PyComplex_FromDoubles()
fromdoubles = _testcapi.complex_fromdoubles
fromdoubles = _testlimitedcapi.complex_fromdoubles
self.assertEqual(fromdoubles(1.0, 2.0), 1.0+2.0j)
def test_realasdouble(self):
# Test PyComplex_RealAsDouble()
realasdouble = _testcapi.complex_realasdouble
realasdouble = _testlimitedcapi.complex_realasdouble
self.assertEqual(realasdouble(1+2j), 1.0)
self.assertEqual(realasdouble(-1+0j), -1.0)
@ -98,7 +99,7 @@ def test_realasdouble(self):
def test_imagasdouble(self):
# Test PyComplex_ImagAsDouble()
imagasdouble = _testcapi.complex_imagasdouble
imagasdouble = _testlimitedcapi.complex_imagasdouble
self.assertEqual(imagasdouble(1+2j), 2.0)
self.assertEqual(imagasdouble(1-1j), -1.0)