Skip to content

Ensure after-commit behaviour is explicit in tests#157

Merged
meshy merged 4 commits into
mainfrom
meshy/ambiguous-after-commit-execution
May 7, 2026
Merged

Ensure after-commit behaviour is explicit in tests#157
meshy merged 4 commits into
mainfrom
meshy/ambiguous-after-commit-execution

Conversation

@meshy
Copy link
Copy Markdown
Collaborator

@meshy meshy commented May 6, 2026

Before this change, after-commit callbacks might be silently dropped by the test suite when run_after_commit was used inside Django's atomic. While this behaviour may be desired in some tests, others might want these callbacks to run.

This change ensures developers decide if after-commit callbacks should be run by ensuring the outer atomic context is opened by Subatomic in any test which calls run_after_commit.

Fixes #147

@meshy meshy marked this pull request as ready for review May 6, 2026 18:35
@meshy meshy requested a review from a team as a code owner May 6, 2026 18:35
Comment thread src/django_subatomic/db.py
@meshy meshy force-pushed the meshy/ambiguous-after-commit-execution branch from 485218d to 6d6d9bc Compare May 6, 2026 18:48
Comment thread CHANGELOG.md Outdated
Comment thread src/django_subatomic/test.py Outdated
meshy added 3 commits May 6, 2026 20:12
This makes it easier to refactor in a later commit.
The logic in this function is about to get bigger, and this early return
saves us from repeating the same check on each if-block.
@meshy meshy force-pushed the meshy/ambiguous-after-commit-execution branch 2 times, most recently from 954d630 to 2af1101 Compare May 7, 2026 08:43
Comment thread docs/reference/settings.md Outdated
Before this change, after-commit callbacks might be silently dropped by
the test suite when `run_after_commit` was used inside Django's
`atomic`. While this behaviour may be desired in some tests, others
might want these callbacks to run.

This change ensures developers decide if after-commit callbacks should
be run by ensuring the outer atomic context is opened by Subatomic in
any test which calls `run_after_commit`.
@meshy meshy force-pushed the meshy/ambiguous-after-commit-execution branch from 2af1101 to 7551249 Compare May 7, 2026 09:05
@meshy meshy merged commit 74dcf4c into main May 7, 2026
8 checks passed
@meshy meshy deleted the meshy/ambiguous-after-commit-execution branch May 7, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run_after_commit should fail in tests if emulation will be ambiguous

2 participants