From 97d2b8329386b08f696d9d47899ee7e96cfb11bc 2013-10-14 23:19:36 From: Thomas Kluyver Date: 2013-10-14 23:19:36 Subject: [PATCH] More concise test summary info --- diff --git a/IPython/testing/iptestcontroller.py b/IPython/testing/iptestcontroller.py index c77d42e..ba7027b 100644 --- a/IPython/testing/iptestcontroller.py +++ b/IPython/testing/iptestcontroller.py @@ -29,7 +29,7 @@ import time from .iptest import have, test_group_names, test_sections from IPython.utils.py3compat import bytes_to_str -from IPython.utils.sysinfo import sys_info +from IPython.utils.sysinfo import brief_sys_info from IPython.utils.tempdir import TemporaryDirectory @@ -206,7 +206,7 @@ def do_run(controller): def report(): """Return a string with a summary report of test-related variables.""" - out = [ sys_info(), '\n'] + out = [ brief_sys_info(), '\n'] avail = [] not_avail = [] @@ -327,17 +327,16 @@ def run_iptestall(options): print('_'*70) print('Test suite completed for system with the following information:') print(report()) - print('Ran %s test groups in %.3fs' % (nrunners, t_tests)) - print() + took = "Took %.3fs." % t_tests print('Status: ', end='') if not failed: - print('OK') + print('OK.', took) else: # If anything went wrong, point out what command to rerun manually to # see the actual errors and individual summary failed_sections = [c.section for c in failed] print('ERROR - {} out of {} test groups failed ({}).'.format(nfail, - nrunners, ', '.join(failed_sections))) + nrunners, ', '.join(failed_sections)), took) print() print('You may wish to rerun these, with:') print(' iptest', *failed_sections) diff --git a/IPython/utils/sysinfo.py b/IPython/utils/sysinfo.py index 69abde2..a3b53c0 100644 --- a/IPython/utils/sysinfo.py +++ b/IPython/utils/sysinfo.py @@ -117,6 +117,34 @@ def sys_info(): path = p.dirname(p.abspath(p.join(__file__, '..'))) return pprint.pformat(pkg_info(path)) +def _compress_user(path): + """Reverse of :func:`os.path.expanduser` + """ + home = os.path.expanduser('~') + if path.startswith(home): + path = "~" + path[len(home):] + return path + +def brief_sys_info(): + """Return summary information about IPython and the system, as a string. + """ + p = os.path + path = p.dirname(p.abspath(p.join(__file__, '..'))) + inf = pkg_info(path) + out = [] + def _add(name, value): + out.append((name, value)) + + _add('IPython version', inf['ipython_version']) + _add('IPython commit', "{} ({})".format(inf['commit_hash'], inf['commit_source'])) + _add('IPython package', _compress_user(inf['ipython_path'])) + _add('Python version', inf['sys_version'].replace('\n','')) + _add('sys.executable', _compress_user(inf['sys_executable'])) + _add('Platform', inf['platform']) + + width = max(len(n) for (n,v) in out) + return '\n'.join("{:<{width}}: {}".format(n, v, width=width) for (n,v) in out) + def _num_cpus_unix(): """Return the number of active CPUs on a Unix system."""