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' )
3537
36- def test_build_c11 (self ):
37- self .check_build ('_test_c11_cext' , std = 'c11' )
38-
39- @unittest .skipIf (support .MS_WINDOWS , "MSVC doesn't support /std:c99" )
40- def test_build_c99 (self ):
41- # In public docs, we say C API is compatible with C11. However,
42- # in practice we do maintain C99 compatibility in public headers.
43- # Please ask the C API WG before adding a new C11-only feature.
44- self .check_build ('_test_c99_cext' , std = 'c99' )
45-
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-
5438 def check_build (self , extension_name , std = None , limited = False ):
5539 venv_dir = 'env'
5640 with support .setup_venv_with_pip_setuptools (venv_dir ) as python_exe :
@@ -70,6 +54,7 @@ def run_cmd(operation, cmd):
7054 if limited :
7155 env ['CPYTHON_TEST_LIMITED' ] = '1'
7256 env ['CPYTHON_TEST_EXT_NAME' ] = extension_name
57+ env ['TEST_INTERNAL_C_API' ] = str (int (self .TEST_INTERNAL_C_API ))
7358 if support .verbose :
7459 print ('Run:' , ' ' .join (map (shlex .quote , cmd )))
7560 subprocess .run (cmd , check = True , env = env )
@@ -110,5 +95,29 @@ def run_cmd(operation, cmd):
11095 run_cmd ('Import' , cmd )
11196
11297
98+ class TestPublicCAPI (BaseTests , unittest .TestCase ):
99+ @support .requires_gil_enabled ('incompatible with Free Threading' )
100+ def test_build_limited (self ):
101+ self .check_build ('_test_limited_cext' , limited = True )
102+
103+ @support .requires_gil_enabled ('broken for now with Free Threading' )
104+ def test_build_limited_c11 (self ):
105+ self .check_build ('_test_limited_c11_cext' , limited = True , std = 'c11' )
106+
107+ def test_build_c11 (self ):
108+ self .check_build ('_test_c11_cext' , std = 'c11' )
109+
110+ @unittest .skipIf (support .MS_WINDOWS , "MSVC doesn't support /std:c99" )
111+ def test_build_c99 (self ):
112+ # In public docs, we say C API is compatible with C11. However,
113+ # in practice we do maintain C99 compatibility in public headers.
114+ # Please ask the C API WG before adding a new C11-only feature.
115+ self .check_build ('_test_c99_cext' , std = 'c99' )
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