Package: nose-timer
A timer plugin for nosetests that answers the question:how much time does every test take?InstallTo install the latest release from PyPI:pip install nose-timerOr to install the latest development version from Git:pip install git+git://github.com/mahmoudimus/nose-timer.gitOr to install the latest from source:git clone https://github.com/mahmoudimus/nose-timer.git
cd nose-timer
pip install .You can also make a developer install if you plan on modifying the
source frequently:pip install -e .UsageRun nosetests with the--with-timerflag, and you will see a list of the
tests and the time spent by each one (in seconds):myapp.tests.ABigTestCase.test_the_world_is_running: 56.0010s
myapp.tests.ABigTestCase.test_the_rest_of_the_galaxy_is_running: 2356.0010sHow do I show only thenslowest tests?For example, to show only the10slowest tests, run nosetests with the--timer-top-nflag:nosetests --with-timer --timer-top-n 10How do I color the output and have pretty colors?You can highlight slower tests using--timer-okand--timer-warningflags.
Default time unit is the second, but you can specify it explicitly, e.g. 1s, 100ms.Tests which take less time than--timer-okwill be highlighted in green.Tests which take less time than--timer-warningwill be highlighted in yellow.All other tests will be highlighted in red.How do I turn off pretty colors?In some cases, you may want to disable colors completely. This is done by using the--timer-no-colorflag. This is useful when running tests in a headless console.How do I filter results by colors?It is possible to filter results by color. To do so, you can use the--timer-filterflag:nosetests --with-timer --timer-filter ok
nosetests --with-timer --timer-filter warning
nosetests --with-timer --timer-filter errorOr to apply several filters at once:nosetests --with-timer --timer-filter warning,errorHow do I cause slow tests to fail?You can cause any tests that exceed a threshold to fail by specifying the--timer-failoption:If you specify--timer-failwarning, slow tests which would be displayed
as a warning (i.e. that take more time than--timer-ok) will fail.If you specify--timer-failerror, slow tests which would be displayed as
an error (i.e. that take more time than--timer-warning) will fail.For example, to fail any tests that take more than 5 seconds:nosetests --with-timer --timer-warning 5.0 --timer-fail errorHow do I export the results ?Use the--timer-json-file<myfile.json>flag, it will save the result
in the following format:{
 'tests':
  {
  '<test key 1>':
    {
      'status': 'success'|'error'|'fail,
      'time': <float in s>
    },
  '<test key 2>':
    {
      'status': 'success'|'error'|'fail,
      'time': <float in s>
    },
   ....
 }Licensenose-timeris MIT Licensed library.ContributeCheck for open issues or open a fresh issue to start a discussion around a
feature idea or a bug.Fork the repository on GitHub to start making your changes to the master
branch (or branch off of it).Write a test which shows that the bug was fixed or that the feature
works as expected.Send a pull request and bug the maintainer until it gets merged and
published.Make sure to add yourself to the author’s file insetup.pyand theContributorssection below :)Contributors@acordiner@andresriancho@cgoldberg@DmitrySandalov@e0ne@ereOn@fisadev@garbageek@HaraldNordgren@hugovk@jakirkham@kevinburke@mahmoudimus@satyrius@skudriashev@whodafly@yarikoptic