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

SlugsAndNumbersTest::test_upsert_keeps_slugs_and_makes_them_unique

First seen 3 weeks ago in 78a4357
CI github-actions:test 12 runs
Average
12 ms
median 13 ms
max 17 ms
Phases
Setup 0.62 ms Call 11 ms Teardown 0.76 ms
Categories
Database 10 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, 16 hours ago · open run
Show pytest frames
call11 ms90.2%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:14855 ms45.1%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:875 ms45.1%
QuerySet.createdjango/db/models/query.py:6695 ms45.1%
Test.saveapps/projects/models.py:2934 ms30.1%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms15.0%
QuerySet.__iter__django/db/models/query.py:3902 ms15.0%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms15.0%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms15.0%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms15.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms15.0%
CursorWrapper.executedjango/db/backends/utils.py:792 ms15.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms15.0%
TestManager.slugs_forapps/projects/models.py:242 taken = set(self.filter(project_id=project_id, slug__in=set(new.values())).values_list("slug", flat=True))2 ms15.0%
QuerySet.__iter__django/db/models/query.py:3902 ms15.0%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms15.0%
FlatValuesListIterable.__iter__django/db/models/query.py:2772 ms15.0%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms15.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16112 ms15.0%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7672 ms15.0%
SQLCompiler.pre_sql_setupdjango/db/models/sql/compiler.py:882 ms15.0%
WhereNode.split_having_qualifydjango/db/models/sql/where.py:472 ms15.0%
Test.saveapps/projects/models.py:294 super().save(*args, **kwargs)2 ms15.0%
Model.savedjango/db/models/base.py:8742 ms15.0%
Model.save_basedjango/db/models/base.py:9662 ms15.0%
Model._save_tabledjango/db/models/base.py:11672 ms15.0%
Model._do_insertdjango/db/models/base.py:12182 ms15.0%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms15.0%
QuerySet._insertdjango/db/models/query.py:19182 ms15.0%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19252 ms15.0%
CursorWrapper.executedjango/db/backends/utils.py:792 ms15.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms15.0%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:1483 again = Test.objects.upsert(self.project, ["tests/test_a.py::test_x[a b]", "tests/test_b.py::test_y"])4 ms30.1%
TestManager.upsertapps/projects/models.py:2292 ms15.0%
TestManager.slugs_forapps/projects/models.py:242 taken = set(self.filter(project_id=project_id, slug__in=set(new.values())).values_list("slug", flat=True))2 ms15.0%
QuerySet.__iter__django/db/models/query.py:3902 ms15.0%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms15.0%
FlatValuesListIterable.__iter__django/db/models/query.py:2772 ms15.0%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms15.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms15.0%
CursorWrapper.executedjango/db/backends/utils.py:792 ms15.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms15.0%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms15.0%
Cursor.executepsycopg/cursor.py:1132 ms15.0%
Connection.waitpsycopg/connection.py:4952 ms15.0%
TestManager.upsertapps/projects/models.py:230 self.bulk_create( # sorted, so uploads sharing tests lock their rows in the same order2 ms15.0%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms15.0%
QuerySet.bulk_createdjango/db/models/query.py:8332 ms15.0%
QuerySet._batched_insertdjango/db/models/query.py:19562 ms15.0%
QuerySet._insertdjango/db/models/query.py:19182 ms15.0%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19252 ms15.0%
CursorWrapper.executedjango/db/backends/utils.py:792 ms15.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms15.0%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms15.0%
Cursor.executepsycopg/cursor.py:1132 ms15.0%
Connection.waitpsycopg/connection.py:4952 ms15.0%
TransactionTestCase._post_teardowndjango/test/testcases.py:1240 self._fixture_teardown()2 ms15.0%
TestCase._fixture_teardowndjango/test/testcases.py:14972 ms15.0%
TestCase._rollback_atomicsdjango/test/testcases.py:14052 ms15.0%
Atomic.__exit__django/db/transaction.py:2832 ms15.0%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:262 ms15.0%
BaseDatabaseWrapper.savepoint_rollbackdjango/db/backends/base/base.py:4132 ms15.0%
BaseDatabaseWrapper._savepoint_rollbackdjango/db/backends/base/base.py:3712 ms15.0%
CursorWrapper.executedjango/db/backends/utils.py:792 ms15.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms15.0%
CursorWrapper._executedjango/db/backends/utils.py:1032 ms15.0%
Cursor.executepsycopg/cursor.py:1132 ms15.0%
Connection.waitpsycopg/connection.py:4952 ms15.0%
Estimated from 6 samples; phase durations are exact. Frames from pytest and pluggy are hidden .

Hot lines in your code

apps/projects/models.py:242
taken = set(self.filter(project_id=project_id, slug__in=set(new.values())).values_list("slug", flat=True))
TestManager.slugs_for · Database
4 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:240
existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))
TestManager.slugs_for · 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
_django_db_marker function 0.04 ms
_django_set_urlconf function 0.04 ms
_template_string_if_invalid_marker function 0.03 ms
_django_clear_site_cache function 0.03 ms
_live_server_helper function 0.03 ms
monkeypatch function 0.02 ms

Database

16 queries · 6 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:1483
9 ms
call _post_teardown
django/test/testcases.py:1240
2 ms

Reliability

12 results · 0 CI failures · 0 local failures

This test hasn't failed recently.

History

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