@@ -393,6 +393,14 @@ def test_ucnhash_capi_reset(self):
393393 out , err = self .run_embedded_interpreter ("test_repeated_init_exec" , code )
394394 self .assertEqual (out , '9\n ' * INIT_LOOPS )
395395
396+
397+ def config_dev_mode (preconfig , config ):
398+ preconfig ['allocator' ] = PYMEM_ALLOCATOR_DEBUG
399+ config ['dev_mode' ] = 1
400+ config ['warnoptions' ] = ['default' ]
401+ config ['faulthandler' ] = 1
402+
403+
396404class InitConfigTests (EmbeddingTestsMixin , unittest .TestCase ):
397405 maxDiff = 4096
398406 UTF8_MODE_ERRORS = ('surrogatepass' if MS_WINDOWS else 'surrogateescape' )
@@ -510,7 +518,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
510518 'check_hash_pycs_mode' : 'default' ,
511519 'pathconfig_warnings' : 1 ,
512520 '_init_main' : 1 ,
513- 'use_frozen_modules' : not support .Py_DEBUG ,
521+ 'use_frozen_modules' : int ( not support .Py_DEBUG ) ,
514522 'safe_path' : 0 ,
515523 '_is_python_build' : IGNORE_CONFIG ,
516524 }
@@ -990,33 +998,26 @@ def test_init_env_dev_mode_alloc(self):
990998 api = API_COMPAT )
991999
9921000 def test_init_dev_mode (self ):
993- preconfig = {
994- 'allocator' : PYMEM_ALLOCATOR_DEBUG ,
995- }
1001+ preconfig = {}
9961002 config = {
997- 'faulthandler' : 1 ,
9981003 'dev_mode' : 1 ,
999- 'warnoptions' : ['default' ],
10001004 }
1005+ config_dev_mode (preconfig , config )
10011006 self .check_all_configs ("test_init_dev_mode" , config , preconfig ,
10021007 api = API_PYTHON )
10031008
10041009 def test_preinit_parse_argv (self ):
10051010 # Pre-initialize implicitly using argv: make sure that -X dev
10061011 # is used to configure the allocation in preinitialization
1007- preconfig = {
1008- 'allocator' : PYMEM_ALLOCATOR_DEBUG ,
1009- }
1012+ preconfig = {}
10101013 config = {
10111014 'argv' : ['script.py' ],
10121015 'orig_argv' : ['python3' , '-X' , 'dev' , '-P' , 'script.py' ],
10131016 'run_filename' : os .path .abspath ('script.py' ),
1014- 'dev_mode' : 1 ,
1015- 'faulthandler' : 1 ,
1016- 'warnoptions' : ['default' ],
10171017 'xoptions' : ['dev' ],
10181018 'safe_path' : 1 ,
10191019 }
1020+ config_dev_mode (preconfig , config )
10201021 self .check_all_configs ("test_preinit_parse_argv" , config , preconfig ,
10211022 api = API_PYTHON )
10221023
@@ -1615,16 +1616,15 @@ def test_init_warnoptions(self):
16151616 'ignore:::PySys_AddWarnOption2' , # PySys_AddWarnOption()
16161617 'ignore:::PyConfig_BeforeRead' , # PyConfig.warnoptions
16171618 'ignore:::PyConfig_AfterRead' ] # PyWideStringList_Append()
1618- preconfig = dict ( allocator = PYMEM_ALLOCATOR_DEBUG )
1619+ preconfig = {}
16191620 config = {
1620- 'dev_mode' : 1 ,
1621- 'faulthandler' : 1 ,
16221621 'bytes_warning' : 1 ,
1623- 'warnoptions' : warnoptions ,
16241622 'orig_argv' : ['python3' ,
16251623 '-Wignore:::cmdline1' ,
16261624 '-Wignore:::cmdline2' ],
16271625 }
1626+ config_dev_mode (preconfig , config )
1627+ config ['warnoptions' ] = warnoptions
16281628 self .check_all_configs ("test_init_warnoptions" , config , preconfig ,
16291629 api = API_PYTHON )
16301630
@@ -1637,6 +1637,21 @@ def test_init_set_config(self):
16371637 self .check_all_configs ("test_init_set_config" , config ,
16381638 api = API_ISOLATED )
16391639
1640+ def test_initconfig_api (self ):
1641+ preconfig = {}
1642+ config = {
1643+ 'dev_mode' : 1 ,
1644+ 'pycache_prefix' : 'conf_pycache_prefix' ,
1645+ 'argv' : ['-c' ],
1646+ 'orig_argv' : ['./_testembed' , '-c' , 'pass' ],
1647+ 'run_command' : 'pass\n ' ,
1648+ 'xoptions' : ['faulthandler' ],
1649+ 'faulthandler' : 1 ,
1650+ }
1651+ config_dev_mode (preconfig , config )
1652+ self .check_all_configs ("test_initconfig_api" , config , preconfig ,
1653+ api = API_PYTHON )
1654+
16401655 def test_get_argc_argv (self ):
16411656 self .run_embedded_interpreter ("test_get_argc_argv" )
16421657 # ignore output
0 commit comments