FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-4080: unittest durations by giampaolo · Pull Request #12271 · python/cpython · GitHub

Repository navigation

bpo-4080: unittest durations - #12271

Merged
giampaolo merged 50 commits into
python:mainfrom
giampaolo:unittest-durations
Apr 2, 2023
Merged

giampaolo merged 50 commits into
python:mainfrom
giampaolo:unittest-durations

Conversation

giampaolo commented Mar 11, 2019 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

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

Comment thread Lib/unittest/runner.py Outdated
Comment thread Doc/library/unittest.rst
Comment thread Doc/library/unittest.rst Outdated

Copy link
Copy Markdown
Contributor Author

Hi @iritkatriel and thanks for taking a look at this. I have merged all test conflicts and polished the implementation a little, since the PR was 3 years and unittest code changed in the meantime.

Comment thread Lib/unittest/runner.py Outdated

Copy link
Copy Markdown
Contributor Author

@LiteApplication thanks for approving. Merging.

Copy link
Copy Markdown

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

This comment was marked as off-topic.

Copy link
Copy Markdown
Member

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

Comment thread Doc/library/unittest.rst
Comment thread Lib/unittest/result.py

giampaolo commented Apr 3, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

@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).

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to 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.


Back | FazBrowse Home | New Git URL