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

SlugsAndNumbersTest::test_upsert_keeps_slugs_and_makes_them_unique

First seen 8 hours ago in 78a4357
CI github-actions:test 5 runs
Average
13 ms
median 14 ms
max 17 ms
Phases
Setup 0.69 ms Call 12 ms Teardown 0.87 ms
Categories
Database 10 ms Other (Unsampled, pytest, Deep copies) 3 ms

16 database queries per run

Needs 0 KB of memory (max 0 KB)

Duration per run

Where the time goes

Latest run in ci:github-actions:test, an hour ago · open run
Hide pytest frames
setup0.86 ms6.3%
CallInfo.from_call_pytest/runner.py:3530.86 ms6.3%
call_and_report.<locals>.<lambda>_pytest/runner.py:2450.86 ms6.3%
HookCaller.__call__pluggy/_hooks.py:5120.86 ms6.3%
PluginManager._hookexecpluggy/_manager.py:1200.86 ms6.3%
_multicallpluggy/_callers.py:1210.86 ms6.3%
pytest_runtest_setup_pytest/runner.py:1650.86 ms6.3%
SetupState.setup_pytest/runner.py:5230.86 ms6.3%
TestCaseFunction.setup_pytest/unittest.py:2270.86 ms6.3%
Function.setup_pytest/python.py:17230.86 ms6.3%
TopRequest._fillfixtures_pytest/fixtures.py:7070.86 ms6.3%
FixtureRequest.getfixturevalue_pytest/fixtures.py:5390.86 ms6.3%
FixtureRequest._get_active_fixturedef_pytest/fixtures.py:6270.86 ms6.3%
FixtureDef.execute_pytest/fixtures.py:11100.86 ms6.3%
HookCaller.__call__pluggy/_hooks.py:5120.86 ms6.3%
PluginManager._hookexecpluggy/_manager.py:1200.86 ms6.3%
_multicallpluggy/_callers.py:1210.86 ms6.3%
pytest_fixture_setup_pytest/fixtures.py:12020.86 ms6.3%
call12 ms89.2%
CallInfo.from_call_pytest/runner.py:35312 ms89.2%
call_and_report.<locals>.<lambda>_pytest/runner.py:24512 ms89.2%
HookCaller.__call__pluggy/_hooks.py:51212 ms89.2%
PluginManager._hookexecpluggy/_manager.py:12012 ms89.2%
_multicallpluggy/_callers.py:12112 ms89.2%
pytest_runtest_call_pytest/runner.py:17912 ms89.2%
_django_setup_unittest.<locals>.non_debugging_runtestpytest_django/plugin.py:57312 ms89.2%
SimpleTestCase.__call__django/test/testcases.py:31312 ms89.2%
SimpleTestCase._setup_and_calldjango/test/testcases.py:36810 ms76.5%
TestCase.__call__<stdlib>/unittest/case.py:74710 ms76.5%
TestCase.run<stdlib>/unittest/case.py:69110 ms76.5%
TestCase._callTestMethod<stdlib>/unittest/case.py:63710 ms76.5%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:1441 tests = Test.objects.upsert(self.project, ["tests/test_a.py::test_x[a b]", "tests/test_a.py::test_x[a-b]"])7 ms51.0%
TestData.__get__django/test/testcases.py:13672 ms12.7%
deepcopy<stdlib>/copy.py:1572 ms12.7%
_reconstruct<stdlib>/copy.py:2552 ms12.7%
deepcopy<stdlib>/copy.py:1252 ms12.7%
_deepcopy_dict<stdlib>/copy.py:2022 ms12.7%
TestManager.upsertapps/projects/models.py:2292 ms12.7%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms12.7%
QuerySet.__iter__django/db/models/query.py:3902 ms12.7%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms12.7%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms12.7%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms12.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
TestManager.upsertapps/projects/models.py:230 self.bulk_create( # sorted, so uploads sharing tests lock their rows in the same order2 ms12.7%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms12.7%
QuerySet.bulk_createdjango/db/models/query.py:8332 ms12.7%
QuerySet._batched_insertdjango/db/models/query.py:19562 ms12.7%
QuerySet._insertdjango/db/models/query.py:19182 ms12.7%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19252 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
TestManager.upsertapps/projects/models.py:236 return {test.name: test for test in self.filter(project=project, name__in=names)}2 ms12.7%
QuerySet.__iter__django/db/models/query.py:3902 ms12.7%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms12.7%
ModelIterable.__iter__django/db/models/query.py:952 ms12.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:14452 ms12.7%
TestManager.upsertapps/projects/models.py:2292 ms12.7%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms12.7%
QuerySet.__iter__django/db/models/query.py:3902 ms12.7%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms12.7%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms12.7%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms12.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:14472 ms12.7%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms12.7%
QuerySet.createdjango/db/models/query.py:6692 ms12.7%
Test.saveapps/projects/models.py:2932 ms12.7%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms12.7%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms12.7%
QuerySet.filterdjango/db/models/query.py:15422 ms12.7%
QuerySet._filter_or_excludedjango/db/models/query.py:15602 ms12.7%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:15702 ms12.7%
Query.add_qdjango/db/models/sql/query.py:16712 ms12.7%
Query._add_qdjango/db/models/sql/query.py:17032 ms12.7%
Query.build_filterdjango/db/models/sql/query.py:15602 ms12.7%
SimpleTestCase._setup_and_calldjango/test/testcases.py:3712 ms12.7%
TransactionTestCase._post_teardowndjango/test/testcases.py:1240 self._fixture_teardown()2 ms12.7%
TestCase._fixture_teardowndjango/test/testcases.py:14952 ms12.7%
DatabaseWrapper.check_constraintsdjango/db/backends/postgresql/base.py:4842 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1032 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
Estimated from 8 samples; phase durations are exact. Frames from pytest and pluggy are shown .

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
5 ms
apps/projects/tests.py:1441
tests = Test.objects.upsert(self.project, ["tests/test_a.py::test_x[a b]", "tests/test_a.py::test_x[a-b]"])
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_unique · Deep copies
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:236
return {test.name: test for test in self.filter(project=project, name__in=names)}
TestManager.upsert · Database
2 ms

Fixtures

Exact setup time
_django_db_marker function 0.05 ms
_live_server_helper function 0.05 ms
_template_string_if_invalid_marker function 0.05 ms
_django_set_urlconf function 0.05 ms
_dj_autoclear_mailbox function 0.04 ms
_django_clear_site_cache function 0.03 ms
monkeypatch function 0.03 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:1441
10 ms
call _post_teardown
django/test/testcases.py:1240
2 ms
setup pytest internals 0.86 ms

Reliability

5 results · 0 CI failures · 0 local failures

This test hasn't failed recently.

History

Latest 5 results, oldest first in the strip
When Environment Outcome Duration Commit
an hour ago CI github-actions:test passed 14 ms 9caa567 main Profile
an hour ago CI github-actions:test passed 13 ms ec75501 main Profile
8 hours ago CI github-actions:test passed 17 ms d2c12e5 main Profile
8 hours ago CI github-actions:test passed 8 ms 0b902f6 main Profile
8 hours ago CI github-actions:test passed 14 ms 78a4357 main Profile