2828@support .requires_venv_with_pip ()
2929@support .requires_subprocess ()
3030@support .requires_resource ('cpu' )
31- class TestExt (unittest .TestCase ):
31+ class BaseTests :
32+ TEST_INTERNAL_C_API = False
33+
3234 # Default build with no options
3335 def test_build (self ):
3436 self .check_build ('_test_cext' )
@@ -43,14 +45,6 @@ def test_build_c99(self):
4345 # Please ask the C API WG before adding a new C11-only feature.
4446 self .check_build ('_test_c99_cext' , std = 'c99' )
4547
46- @support .requires_gil_enabled ('incompatible with Free Threading' )
47- def test_build_limited (self ):
48- self .check_build ('_test_limited_cext' , limited = True )
49-
50- @support .requires_gil_enabled ('broken for now with Free Threading' )
51- def test_build_limited_c11 (self ):
52- self .check_build ('_test_limited_c11_cext' , limited = True , std = 'c11' )
53-
5448 def check_build (self , extension_name , std = None , limited = False ):
5549 venv_dir = 'env'
5650 with support .setup_venv_with_pip_setuptools (venv_dir ) as python_exe :
@@ -70,6 +64,7 @@ def run_cmd(operation, cmd):
7064 if limited :
7165 env ['CPYTHON_TEST_LIMITED' ] = '1'
7266 env ['CPYTHON_TEST_EXT_NAME' ] = extension_name
67+ env ['TEST_INTERNAL_C_API' ] = str (int (self .TEST_INTERNAL_C_API ))
7368 if support .verbose :
7469 print ('Run:' , ' ' .join (map (shlex .quote , cmd )))
7570 subprocess .run (cmd , check = True , env = env )
@@ -110,5 +105,19 @@ def run_cmd(operation, cmd):
110105 run_cmd ('Import' , cmd )
111106
112107
108+ class TestPublicCAPI (BaseTests , unittest .TestCase ):
109+ @support .requires_gil_enabled ('incompatible with Free Threading' )
110+ def test_build_limited (self ):
111+ self .check_build ('_test_limited_cext' , limited = True )
112+
113+ @support .requires_gil_enabled ('broken for now with Free Threading' )
114+ def test_build_limited_c11 (self ):
115+ self .check_build ('_test_limited_c11_cext' , limited = True , std = 'c11' )
116+
117+
118+ class TestInteralCAPI (BaseTests , unittest .TestCase ):
119+ TEST_INTERNAL_C_API = True
120+
121+
113122if __name__ == "__main__" :
114123 unittest .main ()
0 commit comments