summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_embed.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35313: Fix test_embed when run from venv (GH-10713) (GH-10715)Victor Stinner2018-11-261-39/+62
| | | | | | test_embed.InitConfigTests now gets the expected configuration from a child process run with -S to not run the site module. (cherry picked from commit a6537fb7c2f7a007b4ab616c4617afd56d18347d)
* Revert "bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)" ↵Victor Stinner2018-11-221-3/+8
| | | | | (GH-10660) This reverts commit d2be9a5c13221fb84c2221bbfd93efac6111e697.
* bpo-35233: test_embed: fix filesystem encoding (GH-10597)Victor Stinner2018-11-191-2/+4
| | | | Fix InitConfigTests: if utf8_mode is enabled, the expected filesystem encoding is UTF-8.
* bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)Miss Islington (bot)2018-11-161-8/+3
| | | | | | | | | | | | | | * The _PySys_EndInit() function now copies the config->module_search_path list, so config is longer modified when sys.path is updated. * config->warnoptions list and config->xoptions dict are also copied * test_embed: InitConfigTests now also tests main_config['module_search_path'] * Fix _Py_InitializeMainInterpreter(): don't use config->warnoptions but sys.warnoptions to decide if the warnings module should be imported at startup. (cherry picked from commit 37cd982df02795905886ab36a2378ed557cb6f60) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-35233: InitConfigTests tests more config vars (GH-10541) (GH-10546)Victor Stinner2018-11-141-82/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_embed.InitConfigTests tests more configuration variables. Changes: * InitConfigTests tests more core configuration variables: * base_exec_prefix * base_prefix * exec_prefix * home * module_search_path_env * prefix * "_testembed init_from_config" tests more variables: * argv * warnoptions * xoptions * Py_HasFileSystemDefaultEncoding value is no longer tested since it depends on the LC_CTYPE locale and the platform. * 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). * Use more macros in _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict() to reduce code duplication. * Other minor cleanups. (cherry picked from commit 01de89cb59107d4f889aa503a1c0350dae4aebaf)
* bpo-35233: Fix test_embed.InitConfigTests on macOS (GH-10539)Victor Stinner2018-11-141-1/+2
| | | | On macOS and Windows, Py_HasFileSystemDefaultEncoding is 1 by default.
* bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10537)Victor Stinner2018-11-141-1/+1
| | | | Fix _PyMainInterpreterConfig_Copy(): copy 'install_signal_handlers' attribute
* [3.7] bpo-35233: Rewrite test_embed.InitConfigTests (GH-10524) (GH-10529)Victor Stinner2018-11-141-52/+148
| | | | | | | | | | | | | | | | | | | | | * Add C functions: * _Py_GetGlobalVariablesAsDict() * _PyCoreConfig_AsDict() * _PyMainInterpreterConfig_AsDict() * Add new _testcapi methods: * get_global_config() * get_core_config() * get_main_config() * test.pythoninfo: get global, core and main configuration * _testembed now serializes global, core and main configurations using JSON to reuse _Py_GetGlobalVariablesAsDict(), _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict(), rather than duplicating code. * test_embed.InitConfigTests now test much more configuration variables
* Revert "[3.7] bpo-34589: Add -X coerce_c_locale option; C locale coercion ↵Victor Stinner2018-09-191-2/+3
| | | | | off by default (GH-9379)" (GH-9416) This reverts commit 144f1e2c6f4a24bd288c045986842c65cc289684.
* [3.7] bpo-34589: Add -X coerce_c_locale option; C locale coercion off by ↵Victor Stinner2018-09-181-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | default (GH-9379) * bpo-34589: Make _PyCoreConfig.coerce_c_locale private (GH-9371) _PyCoreConfig: * Rename coerce_c_locale to _coerce_c_locale * Rename coerce_c_locale_warn to _coerce_c_locale_warn These fields are now private (name prefixed by "_"). (cherry picked from commit 188ebfa475a6f6aa2d0ea14ca8e1fbe7865b6d27) * bpo-34589: C locale coercion off by default (GH-9073) Py_Initialize() and Py_Main() cannot enable the C locale coercion (PEP 538) anymore: it is always disabled. It can now only be enabled by the Python program ("python3). test_embed: get_filesystem_encoding() doesn't have to set PYTHONUTF8 nor PYTHONCOERCECLOCALE, these variables are already set in the parent. (cherry picked from commit 7a0791b6992d420dc52536257f2f093851ed7215) * bpo-34589: Add -X coerce_c_locale command line option (GH-9378) Add a new -X coerce_c_locale command line option to control C locale coercion (PEP 538). (cherry picked from commit dbdee0073cf0b88fe541980ace1f650900f455cc)
* [3.7] bpo-34247: Fix Python 3.7 initialization (#8659)Victor Stinner2018-08-051-1/+147
| | | | | | | | | | | | | | | | | * -X dev: it is now possible to override the memory allocator using PYTHONMALLOC even if the developer mode is enabled. * Add _Py_InitializeFromConfig() * Add _Py_Initialize_ReadEnvVars() to set global configuration variables from environment variables * Fix the code to initialize Python: Py_Initialize() now also reads environment variables * _Py_InitializeCore() can now be called twice: the second call only replaces the configuration. * Write unit tests on Py_Initialize() and the different ways to configure Python * The isolated mode now always sets Py_IgnoreEnvironmentFlag and Py_NoUserSiteDirectory to 1. * pymain_read_conf() now saves/restores the configuration if the encoding changed
* bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043) (GH-8352)Miss Islington (bot)2018-07-211-0/+8
| | | | | | | | Py_Main() can again be called after Py_Initialize(), as in Python 3.6. The new configuration is ignored, except of _PyMainInterpreterConfig.argv which is used to update sys.argv. (cherry picked from commit fb47bca9ee2d07ce96df94b4e4abafd11826eb01) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33932: Calling Py_Initialize() twice does nothing (GH-7845)Miss Islington (bot)2018-06-221-0/+9
| | | | | | | Calling Py_Initialize() twice does nothing, instead of failing with a fatal error: restore the Python 3.6 behaviour. (cherry picked from commit 209abf746985526bce255e2fba97d3246924885d) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33358: Fix test_embed.test_pre_initialization_sys_options (GH-6612)Miss Islington (bot)2018-04-271-1/+1
| | | | | | Fix test_embed.test_pre_initialization_sys_options() when building with --enable-shared (cherry picked from commit 4114846265536344538ae44cb8ffd8ce2903faf7) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-33042: Fix pre-initialization sys module configuration (GH-6157)Miss Islington (bot)2018-03-251-5/+26
| | | | | | | | | | | - new test case for pre-initialization of sys.warnoptions and sys._xoptions - restored ability to call these APIs prior to Py_Initialize - updated the docs for the affected APIs to make it clear they can be called before Py_Initialize - also enhanced the existing embedding test cases to check for expected settings in the sys module (cherry picked from commit bc77eff8b96be4f035e665ab35c1d06e22f46491) Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
* bpo-20891: Reenable test_embed.test_bpo20891() (GH-5420)Victor Stinner2018-01-291-3/+0
|
* bpo-20891: Skip test_embed.test_bpo20891() (#4967)Victor Stinner2017-12-211-0/+3
| | | | | | Skip the test failing randomly because of known race condition. Skip the test to fix macOS buildbots until a decision is made on the proper fix for the race condition.
* bpo-20891: Fix PyGILState_Ensure() (#4650)Victor Stinner2017-11-301-0/+10
| | | | | | | When PyGILState_Ensure() is called in a non-Python thread before PyEval_InitThreads(), only call PyEval_InitThreads() after calling PyThreadState_New() to fix a crash. Add an unit test in test_embed.
* bpo-32136: Separate embedding tests from C API tests (GH-4567)Nick Coghlan2017-11-271-0/+203
Some parts of the C API are only relevant to larger applications embedding CPython as a runtime engine. The helpers to test those APIs are already separated out into Programs/_testembed.c, this update moves the associated test cases out into their own dedicated test file.