diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2017-06-20 20:16:18 +1200 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@gmail.com> | 2017-06-21 18:09:51 +1200 |
commit | 554b1846367f66a991510bc87156892d69d08c62 (patch) | |
tree | 082ac70a68ea80d26594ab11589b427d02a37046 /numpy/testing/nosetester.py | |
parent | 9614b734452be6a0d6397f6ad03ff20058d4f41b (diff) | |
download | numpy-554b1846367f66a991510bc87156892d69d08c62.tar.gz |
ENH: testing: add a "timer" keyword to ``Tester.test`` to time slow tests.
Useful because no one can remember the magic ``extra_argv`` incantation.
Diffstat (limited to 'numpy/testing/nosetester.py')
-rw-r--r-- | numpy/testing/nosetester.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index ee807fa67..a9ab70fee 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -254,7 +254,7 @@ class NoseTester(object): return NumpyDoctest() def prepare_test_args(self, label='fast', verbose=1, extra_argv=None, - doctests=False, coverage=False): + doctests=False, coverage=False, timer=False): """ Run tests for module using nose. @@ -275,6 +275,12 @@ class NoseTester(object): argv += ['--cover-package=%s' % self.package_name, '--with-coverage', '--cover-tests', '--cover-erase'] + if timer: + if timer is True: + argv += ['--with-timer'] + elif isinstance(timer, int): + argv += ['--with-timer', '--timer-top-n', str(timer)] + # construct list of plugins import nose.plugins.builtin from nose.plugins import EntryPointPluginManager @@ -308,7 +314,8 @@ class NoseTester(object): return argv, plugins def test(self, label='fast', verbose=1, extra_argv=None, - doctests=False, coverage=False, raise_warnings=None): + doctests=False, coverage=False, raise_warnings=None, + timer=False): """ Run tests for module using nose. @@ -342,6 +349,11 @@ class NoseTester(object): - "release" : equals ``()``, don't raise on any warnings. The default is to use the class initialization value. + timer : bool or int, optional + Timing of individual tests with ``nose-timer`` (which needs to be + installed). If True, time tests and report on all of them. + If an integer (say ``N``), report timing results for ``N`` slowest + tests. Returns ------- @@ -448,7 +460,7 @@ class NoseTester(object): from .noseclasses import NumpyTestProgram argv, plugins = self.prepare_test_args( - label, verbose, extra_argv, doctests, coverage) + label, verbose, extra_argv, doctests, coverage, timer) t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins) |