diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-11-14 16:39:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 16:39:45 (GMT) |
commit | 01de89cb59107d4f889aa503a1c0350dae4aebaf (patch) | |
tree | 1b0a002a18efdc053caed59e3c5805570f891449 /Programs/_testembed.c | |
parent | 64313478bcbd0a708c3ce5d4d14f977da56e4be9 (diff) | |
download | cpython-01de89cb59107d4f889aa503a1c0350dae4aebaf.zip cpython-01de89cb59107d4f889aa503a1c0350dae4aebaf.tar.gz cpython-01de89cb59107d4f889aa503a1c0350dae4aebaf.tar.bz2 |
bpo-35233: InitConfigTests tests more config vars (GH-10541)
test_embed.InitConfigTests tests more configuration variables.
Changes:
* InitConfigTests tests more core configuration variables:
* base_exec_prefix
* base_prefix
* exec_prefix
* home
* legacy_windows_fs_encoding
* legacy_windows_stdio
* module_search_path_env
* prefix
* "_testembed init_from_config" tests more variables:
* argv
* warnoptions
* xoptions
* InitConfigTests: add check_global_config(), check_core_config() and
check_main_config() subfunctions to cleanup the code. Move also
constants at the class level (ex: COPY_MAIN_CONFIG).
* Fix _PyCoreConfig_AsDict(): don't set stdio_encoding twice
* Use more macros in _PyCoreConfig_AsDict() and
_PyMainInterpreterConfig_AsDict() to reduce code duplication.
* Other minor cleanups.
Diffstat (limited to 'Programs/_testembed.c')
-rw-r--r-- | Programs/_testembed.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index 12dc0f9..22212bf 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -355,6 +355,7 @@ error: return -1; } + static void dump_config(void) { @@ -468,10 +469,30 @@ static int test_init_from_config(void) Py_SetProgramName(L"./globalvar"); config.program_name = L"./conf_program_name"; - /* FIXME: test argc/argv */ + static wchar_t* argv[2] = { + L"-c", + L"pass", + }; + config.argc = Py_ARRAY_LENGTH(argv); + config.argv = argv; + config.program = L"conf_program"; - /* FIXME: test xoptions */ - /* FIXME: test warnoptions */ + + static wchar_t* xoptions[3] = { + L"core_xoption1=3", + L"core_xoption2=", + L"core_xoption3", + }; + config.nxoption = Py_ARRAY_LENGTH(xoptions); + config.xoptions = xoptions; + + static wchar_t* warnoptions[2] = { + L"default", + L"error::ResourceWarning", + }; + config.nwarnoption = Py_ARRAY_LENGTH(warnoptions); + config.warnoptions = warnoptions; + /* FIXME: test module_search_path_env */ /* FIXME: test home */ /* FIXME: test path config: module_search_path .. dll_path */ @@ -512,6 +533,11 @@ static int test_init_from_config(void) putenv("PYTHONIOENCODING=cp424"); Py_SetStandardStreamEncoding("ascii", "ignore"); +#ifdef MS_WINDOWS + /* Py_SetStandardStreamEncoding() sets Py_LegacyWindowsStdioFlag to 1. + Force it to 0 through the config. */ + config.legacy_windows_stdio = 0; +#endif config.stdio_encoding = "iso8859-1"; config.stdio_errors = "replace"; |