Skip to content

Conversation

@giampaolo
Copy link
Contributor

@giampaologiampaolo commented Mar 11, 2019

Adds cmdline option to show unit-tests durations + summary of the slowest ones, see https://bugs.python.org/issue4080.

Top 5 slowest ones:

$ ./python -m unittest Lib.test.test_ftplib --durations=5 ..........................................s............................................. Slowest test durations ---------------------------------------------------------------------- 0.203s test_with_statement (Lib.test.test_ftplib.TestFTPClass) 0.204s test_retrbinary_rest (Lib.test.test_ftplib.TestTLS_FTPClassMixin) 0.214s test_with_statement (Lib.test.test_ftplib.TestTLS_FTPClassMixin) 0.881s test_mlsd (Lib.test.test_ftplib.TestFTPClass) 1.162s test_mlsd (Lib.test.test_ftplib.TestTLS_FTPClassMixin) ---------------------------------------------------------------------- Ran 88 tests in 5.264s OK (skipped=1) 

All + individual elapsed time:

$ ./python -m unittest Lib.test.test_ftplib --durations=0 -v test_abort (Lib.test.test_ftplib.TestFTPClass) ... [0.002s] ok test_all_errors (Lib.test.test_ftplib.TestFTPClass) ... [0.001s] ok test_cwd (Lib.test.test_ftplib.TestFTPClass) ... [0.001s] ok test_delete (Lib.test.test_ftplib.TestFTPClass) ... [0.001s] ok test_dir (Lib.test.test_ftplib.TestFTPClass) ... [0.041s] ok test_mlsd (Lib.test.test_ftplib.TestFTPClass) ... [0.880s] ok test_nlst (Lib.test.test_ftplib.TestFTPClass) ... [0.092s] ok test_parse257 (Lib.test.test_ftplib.TestFTPClass) ... [0.002s] ok ... Slowest test durations ---------------------------------------------------------------------- 0.000s test__all__ (Lib.test.test_ftplib.MiscTestCase) 0.002s test_pwd (Lib.test.test_ftplib.TestFTPClass) .... 0.140s test_storbinary_rest (Lib.test.test_ftplib.TestTLS_FTPClassMixin) 0.148s test_data_connection (Lib.test.test_ftplib.TestTLS_FTPClass) 0.154s test_storlines (Lib.test.test_ftplib.TestTLS_FTPClassMixin) 0.175s test_retrbinary_rest (Lib.test.test_ftplib.TestTLS_FTPClassMixin) 0.204s test_with_statement (Lib.test.test_ftplib.TestFTPClass) 0.208s test_with_statement (Lib.test.test_ftplib.TestTLS_FTPClassMixin) 0.880s test_mlsd (Lib.test.test_ftplib.TestFTPClass) 1.281s test_mlsd (Lib.test.test_ftplib.TestTLS_FTPClassMixin) ---------------------------------------------------------------------- Ran 88 tests in 5.396s OK (skipped=1) 

https://bugs.python.org/issue4080

@giampaolo
Copy link
ContributorAuthor

@LiteApplication thanks for approving. Merging.

@giampaologiampaolo merged commit 6883007 into python:mainApr 2, 2023
@giampaologiampaolo deleted the unittest-durations branch April 2, 2023 22:13
@eggplants
Copy link

@giampaolo@LiteApplication doesn't appear to be a regular Python reviewer, is it no problem to merge?

@bedevere-bot

This comment was marked as off-topic.

@terryjreedy
Copy link
Member

Hidden buildbot failure was for test_asyncio. I presume unrelated since random test_asyncio failures are unfortunately routine.

@giampaolo
Copy link
ContributorAuthor

giampaolo commented Apr 3, 2023

I created #103209 to address @gpshead's post-merge comments to this PR.

@giampaolo
Copy link
ContributorAuthor

@eggplants wrote:

@giampaolo@LiteApplication doesn't appear to be a regular Python reviewer, is it no problem to merge?

Sorry, I didn't realize that. This was an old PR that unfortunately never received much attention, so it stayed idle for a long time and I occasionally updated it to fix merge conflicts. When I finally saw an approval I was just happy to see it and merged it without further checking. FWIW, I went through these changes multiple times over the last 4 years: I'm confident that the changes introduced in here are OK and are fully retro compatible (this probably was the most sensitive part to consider).

@eggplants
Copy link

Anyway, I am glad this feature has finally been merged. Thank you @giampaolo -san.

@giampaolo
Copy link
ContributorAuthor

Here's a nose issue related to this PR's retro-compatibility: nose-devs/nose2#569.
nose extended TestCase class without defining the new addDuration method. Python 3.12 emitted a warning but it didn't crash.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

12 participants

@giampaolo@tirkarthi@csabella@sperez8@eggplants@bedevere-bot@terryjreedy@gpshead@iritkatriel@ezio-melotti@LiteApplication@the-knights-who-say-ni