mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-116417: Move limited C API abstract.c tests to _testlimitedcapi (#116986)
Split abstract.c and float.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_bytes and test_class.
This commit is contained in:
parent
b1bc37597f
commit
039d20ae54
13 changed files with 780 additions and 728 deletions
|
@ -9,6 +9,7 @@ from test.test_capi.test_getargs import (Float, FloatSubclass, FloatSubclass2,
|
|||
from test.support import import_helper
|
||||
|
||||
_testcapi = import_helper.import_module('_testcapi')
|
||||
_testlimitedcapi = import_helper.import_module('_testlimitedcapi')
|
||||
|
||||
NULL = None
|
||||
|
||||
|
@ -29,7 +30,7 @@ NAN = float("nan")
|
|||
class CAPIFloatTest(unittest.TestCase):
|
||||
def test_check(self):
|
||||
# Test PyFloat_Check()
|
||||
check = _testcapi.float_check
|
||||
check = _testlimitedcapi.float_check
|
||||
|
||||
self.assertTrue(check(4.25))
|
||||
self.assertTrue(check(FloatSubclass(4.25)))
|
||||
|
@ -41,7 +42,7 @@ class CAPIFloatTest(unittest.TestCase):
|
|||
|
||||
def test_checkexact(self):
|
||||
# Test PyFloat_CheckExact()
|
||||
checkexact = _testcapi.float_checkexact
|
||||
checkexact = _testlimitedcapi.float_checkexact
|
||||
|
||||
self.assertTrue(checkexact(4.25))
|
||||
self.assertFalse(checkexact(FloatSubclass(4.25)))
|
||||
|
@ -53,7 +54,7 @@ class CAPIFloatTest(unittest.TestCase):
|
|||
|
||||
def test_fromstring(self):
|
||||
# Test PyFloat_FromString()
|
||||
fromstring = _testcapi.float_fromstring
|
||||
fromstring = _testlimitedcapi.float_fromstring
|
||||
|
||||
self.assertEqual(fromstring("4.25"), 4.25)
|
||||
self.assertEqual(fromstring(b"4.25"), 4.25)
|
||||
|
@ -72,13 +73,13 @@ class CAPIFloatTest(unittest.TestCase):
|
|||
|
||||
def test_fromdouble(self):
|
||||
# Test PyFloat_FromDouble()
|
||||
fromdouble = _testcapi.float_fromdouble
|
||||
fromdouble = _testlimitedcapi.float_fromdouble
|
||||
|
||||
self.assertEqual(fromdouble(4.25), 4.25)
|
||||
|
||||
def test_asdouble(self):
|
||||
# Test PyFloat_AsDouble()
|
||||
asdouble = _testcapi.float_asdouble
|
||||
asdouble = _testlimitedcapi.float_asdouble
|
||||
|
||||
class BadFloat3:
|
||||
def __float__(self):
|
||||
|
@ -109,19 +110,19 @@ class CAPIFloatTest(unittest.TestCase):
|
|||
|
||||
def test_getinfo(self):
|
||||
# Test PyFloat_GetInfo()
|
||||
getinfo = _testcapi.float_getinfo
|
||||
getinfo = _testlimitedcapi.float_getinfo
|
||||
|
||||
self.assertEqual(getinfo(), sys.float_info)
|
||||
|
||||
def test_getmax(self):
|
||||
# Test PyFloat_GetMax()
|
||||
getmax = _testcapi.float_getmax
|
||||
getmax = _testlimitedcapi.float_getmax
|
||||
|
||||
self.assertEqual(getmax(), sys.float_info.max)
|
||||
|
||||
def test_getmin(self):
|
||||
# Test PyFloat_GetMax()
|
||||
getmin = _testcapi.float_getmin
|
||||
getmin = _testlimitedcapi.float_getmin
|
||||
|
||||
self.assertEqual(getmin(), sys.float_info.min)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue