@@ -343,7 +343,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
343
343
344
344
'_install_importlib': 1,
345
345
'check_hash_pycs_mode': 'default',
346
-
'_frozen': 0,
346
+
'pathconfig_warnings': 1,
347
+
'_init_main': 1,
347
348
}
348
349
if MS_WINDOWS:
349
350
DEFAULT_PRE_CONFIG.update({
@@ -371,7 +372,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
371
372
('Py_DontWriteBytecodeFlag', 'write_bytecode', True),
372
373
('Py_FileSystemDefaultEncodeErrors', 'filesystem_errors'),
373
374
('Py_FileSystemDefaultEncoding', 'filesystem_encoding'),
374
-
('Py_FrozenFlag', '_frozen'),
375
+
('Py_FrozenFlag', 'pathconfig_warnings', True),
375
376
('Py_IgnoreEnvironmentFlag', 'use_environment', True),
376
377
('Py_InspectFlag', 'inspect'),
377
378
('Py_InteractiveFlag', 'interactive'),
@@ -500,7 +501,8 @@ def check_global_config(self, config):
500
501
501
502
self.assertEqual(config['global_config'], expected)
502
503
503
-
def check_config(self, testname, expected_config, expected_preconfig, add_path=None):
504
+
def check_config(self, testname, expected_config, expected_preconfig,
505
+
add_path=None, stderr=None):
504
506
env = dict(os.environ)
505
507
# Remove PYTHON* environment variables to get deterministic environment
506
508
for key in list(env):
@@ -511,19 +513,22 @@ def check_config(self, testname, expected_config, expected_preconfig, add_path=N
511
513
env['PYTHONCOERCECLOCALE'] = '0'
512
514
env['PYTHONUTF8'] = '0'
513
515
514
-
out, err = self.run_embedded_interpreter(testname, env=env)
515
-
# Ignore err
516
-
try:
517
-
config = json.loads(out)
518
-
except json.JSONDecodeError:
519
-
self.fail(f"fail to decode stdout: {out!r}")
520
-
521
516
expected_preconfig = dict(self.DEFAULT_PRE_CONFIG, **expected_preconfig)
522
517
expected_config = self.get_expected_config(expected_config, env, add_path)
523
518
for key in self.COPY_PRE_CONFIG:
524
519
if key not in expected_preconfig:
525
520
expected_preconfig[key] = expected_config[key]
526
521
522
+
out, err = self.run_embedded_interpreter(testname, env=env)
523
+
if stderr is None and not expected_config['verbose']:
524
+
stderr = ""
525
+
if stderr is not None:
526
+
self.assertEqual(err.rstrip(), stderr)
527
+
try:
528
+
config = json.loads(out)
529
+
except json.JSONDecodeError:
530
+
self.fail(f"fail to decode stdout: {out!r}")
531
+
527
532
self.check_pre_config(config, expected_preconfig)
528
533
self.check_core_config(config, expected_config)
529
534
self.check_global_config(config)
@@ -689,7 +694,19 @@ def test_init_read_set(self):
689
694
self.check_config("init_read_set", core_config, preconfig,
690
695
add_path="init_read_set_path")
691
696
692
-
def test_run_main_config(self):
697
+
def test_init_run_main(self):
698
+
preconfig = {}
699
+
code = ('import _testinternalcapi, json; '
700
+
'print(json.dumps(_testinternalcapi.get_configs()))')
701
+
core_config = {
702
+
'argv': ['-c', 'arg2'],
703
+
'program': 'python3',
704
+
'program_name': './python3',
705
+
'run_command': code + '\n',
706
+
}
707
+
self.check_config("init_run_main", core_config, preconfig)
708
+
709
+
def test_init_main(self):
693
710
preconfig = {}
694
711
code = ('import _testinternalcapi, json; '
695
712
'print(json.dumps(_testinternalcapi.get_configs()))')
@@ -698,8 +715,10 @@ def test_run_main_config(self):
698
715
'program': 'python3',
699
716
'program_name': './python3',
700
717
'run_command': code + '\n',
718
+
'_init_main': 0,
701
719
}
702
-
self.check_config("run_main_config", core_config, preconfig)
720
+
self.check_config("init_main", core_config, preconfig,
721
+
stderr="Run Python code before _Py_InitializeMain")
703
722
704
723
def test_init_dont_parse_argv(self):
705
724
core_config = {
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4