#34210: Show the duration of individual tests
-------------------------------------+-------------------------------------
               Reporter:  Paolo      |          Owner:  nobody
  Melchiorre                         |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Testing    |        Version:  dev
  framework                          |       Keywords:  test, timing,
               Severity:  Normal     |  durations
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I propose to add the possibility to show the duration of individual tests
 in the final report by ordering them from slowest to fastest and filtering
 only the slowest tests with a threshold.

 Example:

 {{{
 $ python -m manage test --durations=10
 Found 92 test(s).
 Creating test database for alias 'default'...
 System check identified no issues (0 silenced).
 Creating test database for alias 'default'...
 ..........
 ----------------------------------------------------------------------
 Ran 92 tests in 1.297s

 OK
 Destroying test database for alias 'default'...

 Slowest 10 test duration durations:
 0.3597s test_detail_view_with_a_future_poll
 (polls.tests.PollIndexDetailTests)
 0.0284s test_detail_view_with_a_past_poll
 (polls.tests.PollIndexDetailTests)
 0.0068s test_index_view_with_a_future_poll (polls.tests.PollViewTests)
 0.0047s test_index_view_with_a_past_poll (polls.tests.PollViewTests)
 0.0045s test_index_view_with_two_past_polls (polls.tests.PollViewTests)
 0.0041s test_index_view_with_future_poll_and_past_poll
 (polls.tests.PollViewTests)
 0.0036s test_index_view_with_no_polls (polls.tests.PollViewTests)
 0.0003s test_was_published_recently_with_future_poll
 (polls.tests.PollMethodTests)
 0.0002s test_was_published_recently_with_recent_poll
 (polls.tests.PollMethodTests)
 0.0002s test_was_published_recently_with_old_poll
 (polls.tests.PollMethodTests)
 }}}

 `pytest` has a very similar option that helps you find slower tests that
 you want to optimize their timing.
 https://pytest.org/en/latest/how-to/usage.html#durations

 There's an external package `django-slow-tests` that adds a similar
 functionality, but the code is very old and with very little test
 coverage, furthermore the last release was almost 4 years ago and the
 officially supported versions of Django are very old.
 https://github.com/realpython/django-slow-tests

 I propose to add this feature directly into Django tests to help users
 optimize their tests and also to help Django developers optimize the test
 of Dajngo itself.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34210>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701850c5523f1-89dcb1b8-fedb-4553-8263-907f6b0696c8-000000%40eu-central-1.amazonses.com.

Reply via email to