note this test file can t import unittest since the runtime can t currently guarantee that it will not leak memory doing so will mark the test as passing but with reference leaks this can safely import the unittest library once there s a strict guarantee of no leaks during runtime shutdown bpo46417 test that structseq types used by the sys module are still valid when pyfinalizepyinitialize are called multiple times test pytypeobject members obrefcnt tpbase tpbases tpdict tpmro tpname tpsubclasses note this test file can t import unittest since the runtime can t currently guarantee that it will not leak memory doing so will mark the test as passing but with reference leaks this can safely import the unittest library once there s a strict guarantee of no leaks during runtime shutdown bpo 46417 test that structseq types used by the sys module are still valid when py_finalize py_initialize are called multiple times test pytypeobject members ob_refcnt tp_base tp_bases tp_dict tp_mro tp_name tp_subclasses flagstype floatinfotype hash_infotype int_infotype threadinfotype versioninfotype asyncgenhookstype windowsversiontype
import sys
import types









class TestStructSeq:
    
    def _check_structseq(self, obj_type):
        
        assert sys.getrefcount(obj_type) > 1
        
        assert issubclass(obj_type, tuple)
        
        assert obj_type.__bases__ == (tuple,)
        
        assert isinstance(obj_type.__dict__, types.MappingProxyType)
        
        assert obj_type.__mro__ == (obj_type, tuple, object)
        
        assert isinstance(type.__name__, str)
        
        assert obj_type.__subclasses__() == []

    def test_sys_attrs(self):
        for attr_name in (
            'flags',          
            'float_info',     
            'hash_info',      
            'int_info',       
            'thread_info',    
            'version_info',   
        ):
            attr = getattr(sys, attr_name)
            self._check_structseq(type(attr))

    def test_sys_funcs(self):
        func_names = ['get_asyncgen_hooks']  
        if hasattr(sys, 'getwindowsversion'):
            func_names.append('getwindowsversion')  
        for func_name in func_names:
            func = getattr(sys, func_name)
            obj = func()
            self._check_structseq(type(obj))


try:
    tests = TestStructSeq()
    tests.test_sys_attrs()
    tests.test_sys_funcs()
except SystemExit as exc:
    if exc.args[0] != 0:
        raise
print("Tests passed")