Test suite performance
Suite wall time per run
Click a point to open the runWhere the time goes
Avg test time per runSlowest tests
All tests →| Test and why it's slow | Avg |
|---|---|
|
accounts/tests.py::TestSelectedInstance::test_invalid_selected_instance
81% migrations
· fixture django_db_setup (session scope)
pytest_django/fixtures.py:186
|
7.28 s |
|
accounts/tests.py::TestAccountIndexRobots::test_single_facet_is_indexable
81% migrations
· test body
accounts/tests.py:572
|
4.39 s |
|
confs/tests.py::TestConferencePage::test_conference_with_utc_with_date_no_posts
82% migrations
· test body
confs/tests.py:875
|
4.19 s |
|
confs/tests.py::TestMigratedLegacyConferences::test_djangoconus_old_url_redirects
85% migrations
· _post_teardown
django/test/testcases.py:1243
|
3.96 s |
|
accounts/tests.py::TestAccountIndexRobots::test_two_facets_are_noindex
82% migrations
· fixture django_db_setup (session scope)
pytest_django/fixtures.py:186
|
3.14 s |
|
confs/tests.py::TestMigratedLegacyConferences::test_fwd50_date_redirects
84% migrations
· fixture django_db_setup (session scope)
pytest_django/fixtures.py:186
|
3.03 s |
|
confs/tests.py::TestSyncAnnouncements::test_is_idempotent_and_refreshes_unposted_content
87% migrations
· fixture django_db_setup (session scope)
pytest_django/fixtures.py:186
|
2.98 s |
|
confs/tests.py::TestEditConference::test_edit_does_not_change_slug
92% password hashing
· setUp
confs/tests.py:1175
|
1.82 s |
|
confs/tests.py::TestEditConference::test_other_user_forbidden_on_approved_conference
94% password hashing
· setUp
confs/tests.py:1175
|
1.82 s |
|
confs/tests.py::TestEditConference::test_other_user_forbidden
95% password hashing
· setUp
confs/tests.py:1175
|
1.70 s |
Most memory
All tests by memory →Fix next
From the latest run per environment, by time savedUse a fast password hasher in tests
20.5s (30% of test time) is spent hashing passwords. Slow hashing protects real passwords; in tests it only burns CPU.
Details
Only change the hasher in test settings. Tests that assert on a specific hash format need updating.
Where:
- confs/tests.py:1044 TestCreateConference.setUp · 4.14 s
- confs/tests.py:1175 TestEditConference.setUp · 2.81 s
- confs/tests.py:1177 TestEditConference.setUp · 2.63 s
- confs/tests.py:1176 TestEditConference.setUp · 2.58 s
- confs/tests.py:1371 TestApproveConference.setUp · 2.09 s
- confs/tests.py:1372 TestApproveConference.setUp · 2.05 s
- confs/tests.py:1317 TestConferenceApprovalVisibility.setUp · 1.23 s
- confs/tests.py:1316 TestConferenceApprovalVisibility.setUp · 1.23 s
- confs/tests.py:1296 TestUnapproveConference.setUp · 498 ms
- confs/tests.py:1295 TestUnapproveConference.setUp · 496 ms
Most affected tests:
- confs/tests.py::TestEditConference::test_other_user_forbidden
- confs/tests.py::TestEditConference::test_other_user_forbidden_on_approved_conference
- confs/tests.py::TestEditConference::test_edit_does_not_change_slug
- confs/tests.py::TestApproveConference::test_get_not_allowed
- confs/tests.py::TestEditConference::test_owner_can_edit
- confs/tests.py::TestEditConference::test_owner_can_edit_after_approval
- confs/tests.py::TestApproveConference::test_staff_sees_approve_button_on_detail
- fedidevs/tests.py::TestAnonymousCacheAndCsrf::test_authenticated_html_is_private_and_keeps_csrf_header
Use plain static file storage in tests
Static file storage/manifest handling costs 16.0s.
Details
Where:
- accounts/views.py:425 index · 681 ms
- starter_packs/tests.py:841 TestShareStarterPack.test_api_formats · 450 ms
- confs/tests.py:875 TestConferencePage.test_conference_with_utc_with_date_no_posts · 362 ms
- starter_packs/views.py:862 share_starter_pack · 324 ms
- starter_packs/tests.py:125 TestCreateStarterPack.test_form_error · 275 ms
- accounts/tests.py:550 TestAccountIndexRobots.assert_noindex · 272 ms
- starter_packs/tests.py:1027 TestPinAccountInStarterPack.test_pin_button_shown_on_review_page · 269 ms
- confs/views.py:296 _conference_detail · 256 ms
- starter_packs/tests.py:709 TestShareStarterPack.test_logged_in · 225 ms
- starter_packs/tests.py:781 TestShareStarterPack.test_order_by · 214 ms
Most affected tests:
- confs/tests.py::TestConferencePage::test_conference_with_utc_with_date_no_posts
- starter_packs/tests.py::TestPinAccountInStarterPack::test_pin_button_shown_on_review_page
- starter_packs/tests.py::TestCreateStarterPack::test_form_error
- accounts/tests.py::TestSelectedInstance::test_invalid_selected_instance
- starter_packs/tests.py::TestShareStarterPack::test_logged_in
- accounts/tests.py::TestStaticPages::test_developers_on_mastodon
- confs/tests.py::TestMigratedLegacyConferences::test_djangoconus_date_redirects
- starter_packs/tests.py::TestEditStarterPackAccounts::test_not_logged_in
Stop re-running migrations on every test run
Migrations take 16.9s per run, before the first test can start.
Details
CI should still build the database from scratch (no --reuse-db) so broken migrations are caught.
Where:
- confs/tests.py:432 TestLegacyConferenceDataMigration._migrate · 938 ms
- confs/migrations/0031_seed_conference_tags.py:14 seed_conference_tags · 449 ms
- fedidevs/db/postgresql/base.py:39 DatabaseWrapper.get_new_connection · 141 ms
- confs/migrations/0033_remove_legacy_conference_tables.py:388 _get_or_create_conference · 102 ms
- confs/tests.py:412 TestLegacyConferenceDataMigration._leaf_targets · 61 ms
- confs/tests.py:431 TestLegacyConferenceDataMigration._migrate · 55 ms
- confs/migrations/0033_remove_legacy_conference_tables.py:214 _pk_batches · 54 ms
- confs/migrations/0033_remove_legacy_conference_tables.py:398 migrate_legacy_pair · 42 ms
- confs/migrations/0011_conferencepost_alter_conference_posts.py:11 update · 41 ms
- confs/tests.py:430 TestLegacyConferenceDataMigration._migrate · 39 ms
Most affected tests:
- confs/tests.py::TestSyncAnnouncements::test_is_idempotent_and_refreshes_unposted_content
- accounts/tests.py::TestAccountIndexRobots::test_two_facets_are_noindex
- confs/tests.py::TestMigratedLegacyConferences::test_fwd50_date_redirects
- accounts/tests.py::TestSelectedInstance::test_invalid_selected_instance
- confs/tests.py::TestLegacyConferenceDataMigration::test_copies_overlapping_legacy_rows_without_clobbering_existing_data
- confs/tests.py::TestLegacyConferenceDataMigration::test_drops_legacy_tables_when_uniques_are_mysql_style_indexes
Run migrations once, not once per worker
Each of the 4 pytest-xdist workers builds its own test database by running every migration: 19.5s in total, about 4.9s per worker. 14.6s of it repeats work another worker already did.
Details
Every copy is built by the same migrations, so a broken migration still fails the run.
- {'total': 19.52, 'builds': 4, 'workers': 4, 'per_build': 4.88}
CI vs local
Tests that are much slower in CI, and whyUpload profiles from CI and from a developer machine to compare them.
Locally: FLAKYTEST_SECRET_TOKEN=… pytest --flakytest-profile
Failing and flaky tests
| Test | Verdict | CI fails | Local fails |
|---|---|---|---|
| starter_packs/tests.py::TestShareStarterPack::test_api_plain_json | Regression caught | 1/14 | 0/0 |
Environments
Every CI job and developer machine that reported in the last 30 days| Environment | Profiled runs | Avg wall time |
|---|---|---|
| CI github-actions:test | 12 | 38.32 s |
| CI github-actions | 0 | – |