diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-11-14 01:01:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 01:01:52 (GMT) |
commit | 35c28d562ec7249f2a6aef8e326eadac130a1656 (patch) | |
tree | 3a6d8ab6b5348965a80653293b71a6acf4b0b160 /Lib/test/pythoninfo.py | |
parent | 52fb9f14b1b872f088e8110179aa7071fc06bbde (diff) | |
download | cpython-35c28d562ec7249f2a6aef8e326eadac130a1656.zip cpython-35c28d562ec7249f2a6aef8e326eadac130a1656.tar.gz cpython-35c28d562ec7249f2a6aef8e326eadac130a1656.tar.bz2 |
[3.7] bpo-35233: Rewrite test_embed.InitConfigTests (GH-10524) (GH-10529)
* 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
Diffstat (limited to 'Lib/test/pythoninfo.py')
-rw-r--r-- | Lib/test/pythoninfo.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 4a563e9..9257fdf 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -142,7 +142,7 @@ def collect_platform(info_add): info_add('platform.python_implementation', platform.python_implementation()) info_add('platform.platform', - platform.platform(aliased=True, terse=True)) + platform.platform(aliased=True)) def collect_locale(info_add): @@ -525,6 +525,33 @@ def collect_cc(info_add): info_add('CC.version', text) +def collect_gdbm(info_add): + try: + from _gdbm import _GDBM_VERSION + except ImportError: + return + + info_add('gdbm.GDBM_VERSION', '.'.join(map(str, _GDBM_VERSION))) + + +def collect_get_config(info_add): + # Dump global configuration variables, _PyCoreConfig + # and _PyMainInterpreterConfig + try: + from _testcapi import get_global_config, get_core_config, get_main_config + except ImportError: + return + + for prefix, get_config_func in ( + ('global_config', get_global_config), + ('core_config', get_core_config), + ('main_config', get_main_config), + ): + config = get_config_func() + for key in sorted(config): + info_add('%s[%s]' % (prefix, key), repr(config[key])) + + def collect_info(info): error = False info_add = info.add @@ -552,6 +579,8 @@ def collect_info(info): collect_testcapi, collect_resource, collect_cc, + collect_gdbm, + collect_get_config, # Collecting from tests should be last as they have side effects. collect_test_socket, |