Repository navigation
unittest: display time used by each test case #48330
Description
Activity
I've needed to measure each unit test running time
to measure the performance changing of each functionality
that every test case tests.
Latest version of pyunit has only displayed summary running time of the
suite, so I've implemented small enhancement to unittest.py that
(in verbose mode) shows time of each test case run.
Maybe that would be usefull for anybody else?- addedtype-featureA feature request or enhancementA feature request or enhancement
on Oct 8, 2008 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dirTests in the Lib/test dir
on May 17, 2009 Needs test and documentation. Otherwise looks good.
Repack of unittest was good idea. It is a patch against trunk, one test
case is provided and documentation update.The idea is interesting, but I would prefer to have a way to enable/disable this feature (and maybe even specify its format, e.g. the number of decimals). Moving the logic to an external function (possibly used as a decorator) might avoid some code duplication, but OTOH it would probably slow down the execution and the timing a little (I'm not sure that matters though).
Pawel, could you please provide an update wrt Ezio's comment on msg109448, thanks.
I think that a delay time of calling a decorator is not important, because this should be constant in each test execution, so no matter.
I shall be able to provide a patch in few days.
ThanksI am in the process of creating an extension mechanism for unittest which will make adding this sort of use case to unittest much easier. *Even* if it is added to the core it should be in the form of an extension (plugin) so please don't update the patch until this is in place.
piotrdobrogost commented
on Feb 29, 2012 piotrdobrogostmannequinMannequinMore actions@michael Foord
I am in the process of creating an extension mechanism for unittest
which will make adding this sort of use case to unittest much easierHow is it going?
- changed the title
[-]pyunit - display time of each test case - patch[/-][+]unittest: display time of each test case[/+]on Mar 1, 2012 I think this would be a useful feature.
Yes, it would definitely be useful (as would a count of how far through the test run we are [27/129] style). Getting to completing (even for testing) the "extensible" unittest is something I will still do (and nose2 is being built off the prototype work I did), but isn't going to happen immediately - so it's not a good reason to hold up these improvements.
I'll be sprinting at PyCon and look at this issue then.
I'm keen to avoid proliferating command line parameters to the unittest test runner. Ezio - why would you want to disable this feature?
Because it looks like line noise and doesn't provide an useful information in most of the cases (at least for me), see e.g.:
+ test_format (main.MyTestCase) ... [0.000612s] skipped 'not supported in this library version'
+ test_nothing (main.MyTestCase) ... [0.000486s] skipped 'demonstrating skipping'
+ test_windows_support (main.MyTestCase) ... [0.000090s] skipped 'requires Windows'It might still be useful to find the slowest test(s), or for test suites that take a long time (so I'm not opposed to having it as an option that can be enabled if needed), but for most of the tests it will just show an almost meaningless fraction of second.
9 remaining items
I updated the PR for Python 3.9. I think it's ready to be merged. Can someone involved in unittest take a look at it?
- added3.12only security fixesonly security fixesand removed3.9 (EOL)end of lifeend of life
on Nov 25, 2022 - added a commit that references this issue
on Apr 11, 2023 - added a commit that references this issue
on Apr 16, 2023 - added 2 commits that reference this issue
on Apr 17, 2023 Closing, the PR has been merged: #12271 👍
Reacted by Pat Myron
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs