mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-34206: Improve docs and test coverage for pre-init functions (#8023)
- move the Py_Main documentation from the very high level API section to the initialization and finalization section - make it clear that it encapsulates a full Py_Initialize/Finalize cycle of its own - point out that exactly which settings will be read and applied correctly when Py_Main is called after a separate runtime initialization call is version dependent - be explicit that Py_IsInitialized can be called prior to initialization - actually test that Py_IsInitialized can be called prior to initialization - flush stdout in the embedding tests that run code so it appears in the expected order when running with "-vv" - make "-vv" on the subinterpreter embedding tests less spammy --------- Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
This commit is contained in:
parent
93b9e6bd7d
commit
7c4b6a68f2
7 changed files with 198 additions and 77 deletions
|
|
@ -168,7 +168,8 @@ class EmbeddingTestsMixin:
|
|||
# Parse the line from the loop. The first line is the main
|
||||
# interpreter and the 3 afterward are subinterpreters.
|
||||
interp = Interp(*match.groups())
|
||||
if support.verbose > 1:
|
||||
if support.verbose > 2:
|
||||
# 5 lines per pass is super-spammy, so limit that to -vvv
|
||||
print(interp)
|
||||
self.assertTrue(interp.interp)
|
||||
self.assertTrue(interp.tstate)
|
||||
|
|
@ -279,6 +280,10 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
"""
|
||||
env = dict(os.environ, PYTHONPATH=os.pathsep.join(sys.path))
|
||||
out, err = self.run_embedded_interpreter("test_pre_initialization_api", env=env)
|
||||
if support.verbose > 1:
|
||||
print()
|
||||
print(out)
|
||||
print(err)
|
||||
if MS_WINDOWS:
|
||||
expected_path = self.test_exe
|
||||
else:
|
||||
|
|
@ -296,6 +301,10 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
env['PYTHONPATH'] = os.pathsep.join(sys.path)
|
||||
out, err = self.run_embedded_interpreter(
|
||||
"test_pre_initialization_sys_options", env=env)
|
||||
if support.verbose > 1:
|
||||
print()
|
||||
print(out)
|
||||
print(err)
|
||||
expected_output = (
|
||||
"sys.warnoptions: ['once', 'module', 'default']\n"
|
||||
"sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue