Tests / announcements/tests.py
TestPostAnnouncements::test_posts_only_due_announcements
First seen 1 month, 1 week ago in 0c23747
CI
github-actions:test
13 runs
Average
19 ms
median 21 ms
max 32 ms
max 32 ms
Phases
Setup 2 ms
Call 17 ms
Teardown 0.28 ms
Categories
Database 13 ms
Factories 0.18 ms
App code 0.08 ms
Other (Libraries, pytest, Mocking, Unsampled) 6 ms
11 database queries per run
Needs 33 KB of memory (max 52 KB)
Duration per run
Where the time goes
Latest run in ci:github-actions:test, 2 weeks ago ·
open run
setup0.74 ms8.4%
call8 ms89.8%
TestPostAnnouncements.test_posts_only_due_announcementsannouncements/tests.py:53 status_post = self._run_at(dt.datetime(2026, 6, 1, 9, 0, tzinfo=dt.UTC))3 ms33.7%
TestPostAnnouncements._run_atannouncements/tests.py:42 call_command("postannouncements", *([] if dry_run else ["--no-dry-run"]))3 ms33.7%
call_commanddjango/core/management/__init__.py:1952 ms22.4%
RichCommand.executedjango_rich/management/__init__.py:342 ms22.4%
BaseCommand.executedjango/core/management/base.py:4662 ms22.4%
Command.handleannouncements/management/commands/postannouncements.py:26 due = list(Announcement.objects.filter(posted_at__isnull=True, post_at__lte=timezone.now()))1.00 ms11.2%
QuerySet.__iter__django/db/models/query.py:4391.00 ms11.2%
QuerySet._fetch_alldjango/db/models/query.py:22621.00 ms11.2%
ModelIterable.__iter__django/db/models/query.py:1031.00 ms11.2%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251.00 ms11.2%
CursorWrapper.executedjango/db/backends/utils.py:791.00 ms11.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921.00 ms11.2%
Command.handleannouncements/management/commands/postannouncements.py:65 self.console.print(f"Posted {announcement} → {announcement.post_url}")1.00 ms11.2%
Announcement.__str__announcements/models.py:34 return f"Announcement #{self.pk} due {self.post_at:%Y-%m-%d %H:%M}"1.00 ms11.2%
call_commanddjango/core/management/__init__.py:1221.00 ms11.2%
BaseCommand.create_parserdjango/core/management/base.py:3101.00 ms11.2%
CommandParser.__init__django/core/management/base.py:661.00 ms11.2%
ArgumentParser.__init__<stdlib>/argparse.py:20471.00 ms11.2%
_ActionsContainer.add_argument_group<stdlib>/argparse.py:16991.00 ms11.2%
_ArgumentGroup.__init__<stdlib>/argparse.py:19091.00 ms11.2%
_ActionsContainer.__init__<stdlib>/argparse.py:15841.00 ms11.2%
_ActionsContainer._get_handler<stdlib>/argparse.py:18391.00 ms11.2%
TestPostAnnouncements.setUpannouncements/tests.py:18 self.due = baker.make(1.00 ms11.2%
makemodel_bakery/baker.py:1751.00 ms11.2%
Baker.makemodel_bakery/baker.py:4541.00 ms11.2%
Baker._makemodel_bakery/baker.py:5421.00 ms11.2%
Baker.instancemodel_bakery/baker.py:6591.00 ms11.2%
Model.savedjango/db/models/base.py:9041.00 ms11.2%
Model.save_basedjango/db/models/base.py:9961.00 ms11.2%
Model._save_tabledjango/db/models/base.py:11991.00 ms11.2%
Model._do_insertdjango/db/models/base.py:12511.00 ms11.2%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871.00 ms11.2%
QuerySet._insertdjango/db/models/query.py:21411.00 ms11.2%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19351.00 ms11.2%
SQLInsertCompiler.as_sqldjango/db/models/sql/compiler.py:18861.00 ms11.2%
TestPostAnnouncements.setUpannouncements/tests.py:25 self.not_due = baker.make(1.00 ms11.2%
makemodel_bakery/baker.py:1751.00 ms11.2%
Baker.makemodel_bakery/baker.py:4541.00 ms11.2%
Baker._makemodel_bakery/baker.py:5421.00 ms11.2%
Baker.instancemodel_bakery/baker.py:6591.00 ms11.2%
Model.savedjango/db/models/base.py:9041.00 ms11.2%
Model.save_basedjango/db/models/base.py:9961.00 ms11.2%
Model._save_tabledjango/db/models/base.py:11991.00 ms11.2%
Model._do_insertdjango/db/models/base.py:12511.00 ms11.2%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871.00 ms11.2%
QuerySet._insertdjango/db/models/query.py:21411.00 ms11.2%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19361.00 ms11.2%
CursorWrapper.executedjango/db/backends/utils.py:791.00 ms11.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921.00 ms11.2%
CursorWrapper._executedjango/db/backends/utils.py:1051.00 ms11.2%
Cursor.executepsycopg/cursor.py:1131.00 ms11.2%
Connection.waitpsycopg/connection.py:4951.00 ms11.2%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061.00 ms11.2%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861.00 ms11.2%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781.00 ms11.2%
TestPostAnnouncements.test_posts_only_due_announcementsannouncements/tests.py:57 self.due.refresh_from_db()1.00 ms11.2%
Model.refresh_from_dbdjango/db/models/base.py:7881.00 ms11.2%
QuerySet.getdjango/db/models/query.py:7021.00 ms11.2%
QuerySet.__len__django/db/models/query.py:4211.00 ms11.2%
QuerySet._fetch_alldjango/db/models/query.py:22621.00 ms11.2%
ModelIterable.__iter__django/db/models/query.py:1031.00 ms11.2%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251.00 ms11.2%
CursorWrapper.executedjango/db/backends/utils.py:791.00 ms11.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921.00 ms11.2%
CursorWrapper._executedjango/db/backends/utils.py:1051.00 ms11.2%
Cursor.executepsycopg/cursor.py:1131.00 ms11.2%
Connection.waitpsycopg/connection.py:4951.00 ms11.2%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061.00 ms11.2%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861.00 ms11.2%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781.00 ms11.2%
TestPostAnnouncements.test_posts_only_due_announcementsannouncements/tests.py:58 self.not_due.refresh_from_db()1.00 ms11.2%
Model.refresh_from_dbdjango/db/models/base.py:7881.00 ms11.2%
QuerySet.getdjango/db/models/query.py:7021.00 ms11.2%
QuerySet.__len__django/db/models/query.py:4211.00 ms11.2%
QuerySet._fetch_alldjango/db/models/query.py:22621.00 ms11.2%
ModelIterable.__iter__django/db/models/query.py:1031.00 ms11.2%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251.00 ms11.2%
CursorWrapper.executedjango/db/backends/utils.py:791.00 ms11.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921.00 ms11.2%
CursorWrapper._executedjango/db/backends/utils.py:1051.00 ms11.2%
Cursor.executepsycopg/cursor.py:1131.00 ms11.2%
Connection.waitpsycopg/connection.py:4951.00 ms11.2%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061.00 ms11.2%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861.00 ms11.2%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781.00 ms11.2%
TransactionTestCase._post_teardowndjango/test/testcases.py:1243 self._fixture_teardown()1.00 ms11.2%
TestCase._fixture_teardowndjango/test/testcases.py:15001.00 ms11.2%
TestCase._rollback_atomicsdjango/test/testcases.py:14081.00 ms11.2%
Atomic.__exit__django/db/transaction.py:2951.00 ms11.2%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261.00 ms11.2%
BaseDatabaseWrapper.savepoint_rollbackdjango/db/backends/base/base.py:4131.00 ms11.2%
BaseDatabaseWrapper._savepoint_rollbackdjango/db/backends/base/base.py:3711.00 ms11.2%
CursorWrapper.executedjango/db/backends/utils.py:791.00 ms11.2%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921.00 ms11.2%
Estimated from 9 samples; phase durations are exact. Frames from pytest and pluggy are
hidden
.
Hot lines in your code
|
announcements/tests.py:18
self.due = baker.make(
TestPostAnnouncements.setUp
· Database
|
1 ms |
|
announcements/tests.py:25
self.not_due = baker.make(
TestPostAnnouncements.setUp
· Database
|
1 ms |
|
announcements/tests.py:42
call_command("postannouncements", *([] if dry_run else ["--no-dry-run"]))
TestPostAnnouncements._run_at
· Libraries
|
1 ms |
|
announcements/management/commands/postannouncements.py:26
due = list(Announcement.objects.filter(posted_at__isnull=True, post_at__lte=timezone.now()))
Command.handle
· Database
|
1 ms |
|
announcements/models.py:34
return f"Announcement #{self.pk} due {self.post_at:%Y-%m-%d %H:%M}"
Announcement.__str__
· App code
|
1 ms |
|
announcements/tests.py:57
self.due.refresh_from_db()
TestPostAnnouncements.test_posts_only_due_announcements
· Database
|
1 ms |
|
announcements/tests.py:58
self.not_due.refresh_from_db()
TestPostAnnouncements.test_posts_only_due_announcements
· Database
|
1 ms |
Fixtures
Exact setup time| _live_server_helper function | 0.15 ms |
| _django_db_marker function | 0.03 ms |
| _template_string_if_invalid_marker function | 0.03 ms |
| _dj_autoclear_mailbox function | 0.03 ms |
| _django_isolate_apps function | 0.03 ms |
| _django_set_urlconf function | 0.03 ms |
| _django_clear_site_cache function | 0.02 ms |
| monkeypatch function | 0.02 ms |
Database
11 queries · 3 ms
Repeated queries are usually N+1 lookups: fetch them once with select_related / prefetch_related (or selectinload).
3×
SELECT "announcements_announcement"."id", "announcements_announcement"."content", "announcements_announcement"."visibility", "announcements_announcement"."post_at", "announcements_announcement"."posted_at", "announcements_announcement"."post_url", "announcements_announcement"."error", "announcement…
Biggest pieces of work
|
call test body
announcements/tests.py:53
|
5 ms |
|
call setUp
announcements/tests.py:18
|
2 ms |
|
call _post_teardown
django/test/testcases.py:1243
|
1 ms |
| setup pytest internals | 0.74 ms |
Reliability
14 results · 0 CI failures · 0 local failuresThis test hasn't failed recently.
History
Latest 14 results, oldest first in the strip| When | Environment | Outcome | Duration | |
|---|---|---|---|---|
| 2 weeks ago | CI github-actions:test | passed | 9 ms | Profile |
| 2 weeks, 5 days ago | CI github-actions:test | passed | 30 ms | Profile |
| 2 weeks, 6 days ago | CI github-actions:test | passed | 15 ms | Profile |
| 3 weeks ago | CI github-actions:test | passed | 11 ms | Profile |
| 3 weeks ago | CI github-actions:test | passed | 25 ms | Profile |
| 1 month ago | CI github-actions:test | passed | 11 ms | Profile |
| 1 month ago | CI github-actions:test | passed | 26 ms | Profile |
| 1 month ago | CI github-actions:test | passed | 12 ms | Profile |
| 1 month, 1 week ago | CI github-actions:test | passed | 26 ms | Profile |
| 1 month, 1 week ago | CI github-actions:test | passed | 10 ms | Profile |
| 1 month, 1 week ago | CI github-actions:test | passed | 21 ms | Profile |
| 1 month, 1 week ago | CI github-actions:test | passed | 21 ms | Profile |
| 1 month, 1 week ago | CI github-actions:test | passed | 32 ms | Profile |
| 1 month, 1 week ago | CI github-actions:test | passed | 10 ms | Run |