28
28
@support .requires_venv_with_pip ()
29
29
@support .requires_subprocess ()
30
30
@support .requires_resource ('cpu' )
31
- class TestExt (unittest .TestCase ):
31
+ class BaseTests :
32
+ TEST_INTERNAL_C_API = False
33
+
32
34
# Default build with no options
33
35
def test_build (self ):
34
36
self .check_build ('_test_cext' )
35
37
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
-
54
38
def check_build (self , extension_name , std = None , limited = False ):
55
39
venv_dir = 'env'
56
40
with support .setup_venv_with_pip_setuptools (venv_dir ) as python_exe :
@@ -70,6 +54,7 @@ def run_cmd(operation, cmd):
70
54
if limited :
71
55
env ['CPYTHON_TEST_LIMITED' ] = '1'
72
56
env ['CPYTHON_TEST_EXT_NAME' ] = extension_name
57
+ env ['TEST_INTERNAL_C_API' ] = str (int (self .TEST_INTERNAL_C_API ))
73
58
if support .verbose :
74
59
print ('Run:' , ' ' .join (map (shlex .quote , cmd )))
75
60
subprocess .run (cmd , check = True , env = env )
@@ -110,5 +95,29 @@ def run_cmd(operation, cmd):
110
95
run_cmd ('Import' , cmd )
111
96
112
97
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
+
113
122
if __name__ == "__main__" :
114
123
unittest .main ()
0 commit comments