summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-12-13 16:27:40 (GMT)
committerGitHub <noreply@github.com>2017-12-13 16:27:40 (GMT)
commit981469794af8c693174544265b0c19cbe6d2b457 (patch)
tree43ade58c05219f5ecb5ff2d63d26c7f39de23f88 /Lib
parent7a6706bf481070298d603b2e3140be715e9dfdcb (diff)
downloadcpython-981469794af8c693174544265b0c19cbe6d2b457.zip
cpython-981469794af8c693174544265b0c19cbe6d2b457.tar.gz
cpython-981469794af8c693174544265b0c19cbe6d2b457.tar.bz2
pythoninfo: Add builtins, test.support, ... (#4840)
Collect more info from builtins, resource, test.test_socket and test.support modules. Co-Authored-By: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/pythoninfo.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 7ad076d..9ca26c9 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -151,6 +151,11 @@ def collect_locale(info_add):
info_add('locale.encoding', locale.getpreferredencoding(False))
+def collect_builtins(info_add):
+ info_add('builtins.float.float_format', float.__getformat__("float"))
+ info_add('builtins.float.double_format', float.__getformat__("double"))
+
+
def collect_os(info_add):
import os
@@ -170,7 +175,7 @@ def collect_os(info_add):
)
copy_attributes(info_add, os, 'os.%s', attributes, formatter=format_attr)
- info_add("os.cwd", os.getcwd())
+ call_func(info_add, 'os.cwd', os, 'getcwd')
call_func(info_add, 'os.uid', os, 'getuid')
call_func(info_add, 'os.gid', os, 'getgid')
@@ -435,6 +440,44 @@ def collect_testcapi(info_add):
copy_attr(info_add, 'pymem.with_pymalloc', _testcapi, 'WITH_PYMALLOC')
+def collect_resource(info_add):
+ try:
+ import resource
+ except ImportError:
+ return
+
+ limits = [attr for attr in dir(resource) if attr.startswith('RLIMIT_')]
+ for name in limits:
+ key = getattr(resource, name)
+ value = resource.getrlimit(key)
+ info_add('resource.%s' % name, value)
+
+
+def collect_test_socket(info_add):
+ try:
+ from test import test_socket
+ except ImportError:
+ return
+
+ # all check attributes like HAVE_SOCKET_CAN
+ attributes = [name for name in dir(test_socket)
+ if name.startswith('HAVE_')]
+ copy_attributes(info_add, test_socket, 'test_socket.%s', attributes)
+
+
+def collect_test_support(info_add):
+ try:
+ from test import support
+ except ImportError:
+ return
+
+ attributes = ('IPV6_ENABLED',)
+ copy_attributes(info_add, support, 'test_support.%s', attributes)
+
+ call_func(info_add, 'test_support._is_gui_available', support, '_is_gui_available')
+ call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
+
+
def collect_info(info):
error = False
info_add = info.add
@@ -443,6 +486,7 @@ def collect_info(info):
# collect_os() should be the first, to check the getrandom() status
collect_os,
+ collect_builtins,
collect_gdb,
collect_locale,
collect_platform,
@@ -458,6 +502,11 @@ def collect_info(info):
collect_expat,
collect_decimal,
collect_testcapi,
+ collect_resource,
+
+ # Collecting from tests should be last as they have side effects.
+ collect_test_socket,
+ collect_test_support,
):
try:
collect_func(info_add)