GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-4080: unittest durations by giampaolo · Pull Request #12271 · python/cpython

Conversation

@giampaolo

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

Uh oh!

There was an error while loading. Please reload this page.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dfrankow, manuel-91, jdufresne, sperez8, 153957, TAAPArthur, philbucher, andprosoft, calumah, eggplants, and 9 more reacted with thumbs up emoji eggplants reacted with rocket emoji
All reactions
  • 👍 19 reactions
  • 🚀 1 reaction
giampaolo added 21 commits March 10, 2019 04:58
@giampaolo
print durations
6f0b1fe
@giampaolo
don't print duration if not verbose
2b16e57
@giampaolo
add cmdline arg (bool) to toggle durations
49aa791
@giampaolo
make --durations arg accept a mandatory int value
4830509
@giampaolo
print durations
f8a49d3
@giampaolo
hide durations < 0.000
875e93d
@giampaolo
minor cosmetic changes
59dfc67
@giampaolo
don't use bare except clause
c92bc24
@giampaolo
add a public addDuration method to TestResult
d88087e
@giampaolo
fix TypeError occurring on skip
1952ffa
@giampaolo
Merge branch 'master' into unittest-durations
9f308dc
@giampaolo
fix unit tests
226288a
@giampaolo
add a couple of tests for runner
89e915f
@giampaolo
don't add durations multiple times + write durations test
968c3af
@giampaolo
don't print header if there are no durations
a8b38e9
@giampaolo
small refactoring
f95edc7
@giampaolo
add doc
9beb931
@giampaolo
update doc
86fc3f8
@giampaolo
improve test
a1f5e49
@giampaolo
use example from stdlib
9d98536
@giampaolo
ignore me
7223bc9
@bedevere-bot bedevere-bot added the awaiting merge label Mar 11, 2019
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 11, 2019
tirkarthi
tirkarthi reviewed Apr 25, 2019
View reviewed changes
Comment thread Lib/unittest/runner.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tirkarthi
tirkarthi reviewed Apr 25, 2019
View reviewed changes
Comment thread Doc/library/unittest.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

giampaolo added 3 commits April 26, 2019 10:01
@giampaolo
merge from master
3c4af91
@giampaolo
address PR review (amongst which, show slowest tests firsts)
3f4d638
@giampaolo
update doc samples
b3bb3e0
tirkarthi
tirkarthi reviewed Apr 26, 2019
View reviewed changes
Comment thread Doc/library/unittest.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@giampaolo
fix doc syntax
a93b460
giampaolo added 4 commits November 24, 2022 22:14
@giampaolo
move TextRunner test in test_runner.py
b2b37ad
Signed-off-by: Giampaolo Rodola <[email protected]>
@giampaolo
improve unit test
2b7f3dc
@giampaolo
remove code which is no longer used
cfd65b0
@giampaolo
Merge branch 'main' into unittest-durations
4772f96
@giampaolo

giampaolo commented Nov 24, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ezio-melotti
ezio-melotti reviewed Nov 28, 2022
View reviewed changes
Comment thread Lib/unittest/runner.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2022-11-24-13-23-07.gh-issue-48330.6uAX9F.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

giampaolo added 2 commits November 28, 2022 10:20
@giampaolo
Merge branch 'main' into unittest-durations
3ea0be8
@giampaolo
address @ezio-melotti code review comments
19f9c4b
Signed-off-by: Giampaolo Rodola <[email protected]>
LiteApplication
LiteApplication approved these changes Apr 2, 2023
View reviewed changes
giampaolo added 3 commits April 2, 2023 23:21
@giampaolo
Merge branch 'main' into unittest-durations
ed5f317
@giampaolo
Update 3.12.rst
e6d3b58
@giampaolo
Update 3.12.rst
90a3d70
@giampaolo

giampaolo commented Apr 2, 2023

Copy link
Copy Markdown
Contributor Author

@LiteApplication thanks for approving. Merging.

eggplants reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eggplants

eggplants commented Apr 2, 2023

Copy link
Copy Markdown

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

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

This comment was marked as off-topic.

Sign in to view
@terryjreedy

terryjreedy commented Apr 3, 2023

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gpshead
gpshead reviewed Apr 3, 2023
View reviewed changes
Comment thread Doc/library/unittest.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_unittest/test_runner.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/unittest/result.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@giampaolo giampaolo mentioned this pull request Apr 3, 2023
gh-48330: address review comments to PR-12271 #103209
Merged
@giampaolo

giampaolo commented Apr 3, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@giampaolo

giampaolo commented Apr 3, 2023

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

eggplants reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eggplants

eggplants commented Apr 3, 2023

Copy link
Copy Markdown

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

giampaolo reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel iritkatriel mentioned this pull request Apr 6, 2023
gh-48330: assert warning is emitted on unittest.TestResult with no addDuration #103309
Merged
@masklinn masklinn mentioned this pull request Apr 6, 2023
Add addDuration to TestCaseFunction pytest-dev/pytest#10875
Closed
@giampaolo giampaolo mentioned this pull request Apr 20, 2023
GitHub tests are failing on Python 3.12 alpha 7 nose-devs/nose2#569
Closed
@giampaolo

giampaolo commented Apr 26, 2023

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bityob bityob mentioned this pull request Jul 14, 2023
Leaked semaphore objects in test_concurrent_futures #104090
Open
@Eclips4 Eclips4 mentioned this pull request Aug 12, 2023
test_socket leaks file descriptors on macOS #80931
Open
@adiroiban adiroiban mentioned this pull request Dec 19, 2023
[#12052] Update distributed trial for the changed skip behaviour in 3.12.1 twisted/twisted#12054
Merged
This was referenced Sep 2, 2026
Add duration summary reporting to trial similar to stdlib twisted/twisted#12833
Open
Github Actions on MacOS 15 runs extremely slowly due to sockets.getfqdn() twisted/twisted#12832
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead gpshead left review comments
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
@iritkatriel iritkatriel Awaiting requested review from iritkatriel
@tirkarthi tirkarthi Awaiting requested review from tirkarthi
@ezio-melotti ezio-melotti Awaiting requested review from ezio-melotti
+1 more reviewer
@LiteApplication LiteApplication LiteApplication approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

12 participants

@giampaolo @tirkarthi @csabella @sperez8 @eggplants @bedevere-bot @terryjreedy @gpshead @iritkatriel @ezio-melotti @LiteApplication @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.