flakytest.dev anze3db flakytest
Tests / apps/projects/tests.py

SlugsAndNumbersTest::test_upsert_keeps_slugs_and_makes_them_unique

First seen 1 month, 1 week ago in 78a4357
CI github-actions:test 15 runs
Average
12 ms
median 13 ms
max 18 ms
Phases
Setup 0.59 ms Call 11 ms Teardown 0.79 ms
Categories
Database 10 ms App code 0.12 ms Other (Unsampled, pytest, Deep copies, Mocking) 2 ms

16 database queries per run

Needs 0 KB of memory (max 4 KB)

Duration per run

Where the time goes

Latest run in ci:github-actions:test, 2 weeks ago · open run
Show pytest frames
call9 ms91.0%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:1495 tests = Test.objects.upsert(self.project, ["tests/test_a.py::test_x[a b]", "tests/test_a.py::test_x[a-b]"])5 ms54.6%
TestManager.upsertapps/projects/models.py:2292 ms18.2%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms18.2%
QuerySet.__iter__django/db/models/query.py:3902 ms18.2%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms18.2%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms18.2%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms18.2%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms18.2%
CursorWrapper.executedjango/db/backends/utils.py:792 ms18.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms18.2%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms18.2%
Cursor.executepsycopg/cursor.py:1132 ms18.2%
Connection.waitpsycopg/connection.py:4952 ms18.2%
TestManager.upsertapps/projects/models.py:231 [Test(project=project, name=name, slug=slugs[name], first_commit=first_commit) for name in names],2 ms18.2%
TestManager.upsertapps/projects/models.py:230 self.bulk_create( # sorted, so uploads sharing tests lock their rows in the same order2 ms18.2%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms18.2%
QuerySet.bulk_createdjango/db/models/query.py:8332 ms18.2%
QuerySet._batched_insertdjango/db/models/query.py:19562 ms18.2%
QuerySet._insertdjango/db/models/query.py:19182 ms18.2%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19352 ms18.2%
BaseDatabaseOperations.fetch_returned_rowsdjango/db/backends/base/operations.py:3782 ms18.2%
DatabaseErrorWrapper.__call__.<locals>.innerdjango/db/utils.py:1012 ms18.2%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:15014 ms36.4%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:874 ms36.4%
QuerySet.createdjango/db/models/query.py:6694 ms36.4%
Test.saveapps/projects/models.py:2932 ms18.2%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms18.2%
QuerySet.__iter__django/db/models/query.py:3902 ms18.2%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms18.2%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms18.2%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms18.2%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms18.2%
CursorWrapper.executedjango/db/backends/utils.py:792 ms18.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms18.2%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms18.2%
Cursor.executepsycopg/cursor.py:1132 ms18.2%
Connection.waitpsycopg/connection.py:4952 ms18.2%
Test.saveapps/projects/models.py:294 super().save(*args, **kwargs)2 ms18.2%
Model.savedjango/db/models/base.py:8742 ms18.2%
Model.save_basedjango/db/models/base.py:9662 ms18.2%
Model._save_tabledjango/db/models/base.py:11672 ms18.2%
Model._do_insertdjango/db/models/base.py:12182 ms18.2%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms18.2%
QuerySet._insertdjango/db/models/query.py:19182 ms18.2%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19252 ms18.2%
CursorWrapper.executedjango/db/backends/utils.py:792 ms18.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms18.2%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms18.2%
Cursor.executepsycopg/cursor.py:1132 ms18.2%
Connection.waitpsycopg/connection.py:4952 ms18.2%
Estimated from 5 samples; phase durations are exact. Frames from pytest and pluggy are hidden .

Hot lines in your code

apps/projects/models.py:240
existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))
TestManager.slugs_for · Database
4 ms
apps/projects/models.py:231
[Test(project=project, name=name, slug=slugs[name], first_commit=first_commit) for name in names],
TestManager.upsert · App code
2 ms
apps/projects/models.py:230
self.bulk_create( # sorted, so uploads sharing tests lock their rows in the same order
TestManager.upsert · Database
2 ms
apps/projects/models.py:294
super().save(*args, **kwargs)
Test.save · Database
2 ms

Fixtures

Exact setup time
_dj_autoclear_mailbox function 0.04 ms
_template_string_if_invalid_marker function 0.03 ms
_django_db_marker function 0.03 ms
_django_set_urlconf function 0.03 ms
_live_server_helper function 0.02 ms
_django_clear_site_cache function 0.02 ms
monkeypatch function 0.01 ms

Database

16 queries · 4 ms

Repeated queries are usually N+1 lookups: fetch them once with select_related / prefetch_related (or selectinload).

3×
SELECT "projects_test"."name" AS "name", "projects_test"."slug" AS "slug" FROM "projects_test" WHERE ("projects_test"."name" IN (…) AND "projects_test"."project_id" = %s)
3×
SELECT "projects_test"."slug" AS "slug" FROM "projects_test" WHERE ("projects_test"."project_id" = %s AND "projects_test"."slug" IN (…))

Biggest pieces of work

call test body
apps/projects/tests.py:1495
9 ms

Reliability

15 results · 0 CI failures · 0 local failures

This test hasn't failed recently.

History

Latest 15 results, oldest first in the strip
When Environment Outcome Duration Commit
2 weeks ago CI github-actions:test passed 10 ms cb18ed3 main Profile
2 weeks, 4 days ago CI github-actions:test passed 18 ms 9bd5864 main Profile
2 weeks, 6 days ago CI github-actions:test passed 8 ms 19dac9b main Profile
3 weeks ago CI github-actions:test passed 12 ms e141198 main Profile
1 month ago CI github-actions:test passed 8 ms 46ec2aa main Profile
1 month ago CI github-actions:test passed 13 ms afde85b main Profile
1 month ago CI github-actions:test passed 11 ms fe29f9d main Profile
1 month ago CI github-actions:test passed 14 ms 044719a main Profile
1 month ago CI github-actions:test passed 9 ms b3fedae main Profile
1 month, 1 week ago CI github-actions:test passed 15 ms 43c4eda main Profile
1 month, 1 week ago CI github-actions:test passed 14 ms 9caa567 main Profile
1 month, 1 week ago CI github-actions:test passed 13 ms ec75501 main Profile
1 month, 1 week ago CI github-actions:test passed 17 ms d2c12e5 main Profile
1 month, 1 week ago CI github-actions:test passed 8 ms 0b902f6 main Profile
1 month, 1 week ago CI github-actions:test passed 14 ms 78a4357 main Profile