bpo-4080: unittest durations by giampaolo · Pull Request #12271 · python/cpython (original) (raw)
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)