mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00

* Set a bit in the unused part of the refcount on 64 bit machines and the free-threaded build. * Use the top of the refcount range on 32 bit machines
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import unittest
|
|
from test.support import import_helper
|
|
|
|
_testcapi = import_helper.import_module('_testcapi')
|
|
_testinternalcapi = import_helper.import_module('_testinternalcapi')
|
|
|
|
|
|
class TestCAPI(unittest.TestCase):
|
|
def test_immortal_builtins(self):
|
|
_testcapi.test_immortal_builtins()
|
|
|
|
def test_immortal_small_ints(self):
|
|
_testcapi.test_immortal_small_ints()
|
|
|
|
class TestInternalCAPI(unittest.TestCase):
|
|
|
|
def test_immortal_builtins(self):
|
|
for obj in range(-5, 256):
|
|
self.assertTrue(_testinternalcapi.is_static_immortal(obj))
|
|
self.assertTrue(_testinternalcapi.is_static_immortal(None))
|
|
self.assertTrue(_testinternalcapi.is_static_immortal(False))
|
|
self.assertTrue(_testinternalcapi.is_static_immortal(True))
|
|
self.assertTrue(_testinternalcapi.is_static_immortal(...))
|
|
self.assertTrue(_testinternalcapi.is_static_immortal(()))
|
|
for obj in range(300, 400):
|
|
self.assertFalse(_testinternalcapi.is_static_immortal(obj))
|
|
for obj in ([], {}, set()):
|
|
self.assertFalse(_testinternalcapi.is_static_immortal(obj))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|