@@ -1336,6 +1336,39 @@ def test_configured_settings(self):
13361336
13371337 self .assertEqual (settings , expected )
13381338
1339+ @unittest .skipIf (_testsinglephase is None , "test requires _testsinglephase module" )
1340+ @unittest .skipUnless (hasattr (os , "pipe" ), "requires os.pipe()" )
1341+ def test_setting_extensions_subinterp_check (self ):
1342+ """
1343+ This verifies that the interpreter's configured setting
1344+ is used during import.
1345+ """
1346+ import json
1347+
1348+ for enabled in (True , False ):
1349+ label = 'enabled' if enabled else 'disabled'
1350+ with self .subTest (f'config: check { label } ' ):
1351+ kwargs = {
1352+ 'allow_fork' : True ,
1353+ 'allow_exec' : True ,
1354+ 'allow_threads' : True ,
1355+ 'allow_daemon_threads' : True ,
1356+ 'check_multi_interp_extensions' : enabled ,
1357+ }
1358+
1359+ r , w = os .pipe ()
1360+ script = textwrap .dedent (f'''
1361+ from test.test_capi import check_config
1362+ check_config.run_singlephase_check({ w } )
1363+ ''' )
1364+ with os .fdopen (r ) as stdout :
1365+ ret = support .run_in_subinterp_with_config (script , ** kwargs )
1366+ self .assertEqual (ret , 0 )
1367+ out = stdout .read ()
1368+ results = json .loads (out )
1369+
1370+ self .assertEqual (results , {'allowed' : not enabled })
1371+
13391372 @unittest .skipIf (_testsinglephase is None , "test requires _testsinglephase module" )
13401373 @unittest .skipUnless (hasattr (os , "pipe" ), "requires os.pipe()" )
13411374 def test_overridden_setting_extensions_subinterp_check (self ):
@@ -1387,8 +1420,8 @@ def check(enabled, override):
13871420
13881421 r , w = os .pipe ()
13891422 script = textwrap .dedent (f'''
1390- from test.test_capi.check_config import run_singlephase_check
1391- run_singlephase_check ({ override } , { w } )
1423+ from test.test_capi import check_config
1424+ check_config.run_singlephase_override_check ({ override } , { w } )
13921425 ''' )
13931426 with os .fdopen (r ) as stdout :
13941427 ret = support .run_in_subinterp_with_config (script , ** kwargs )
0 commit comments