Skip to content

Control after-commit calls in tests with a setting#23

Merged
meshy merged 1 commit intomainfrom
transaction-callback-simulation-setting
Sep 17, 2025
Merged

Control after-commit calls in tests with a setting#23
meshy merged 1 commit intomainfrom
transaction-callback-simulation-setting

Conversation

@meshy
Copy link
Collaborator

@meshy meshy commented Sep 17, 2025

By default, in (non transaction testcase) tests, we simulate the execution of after-commit callbacks, to reproduce Django's normal behaviour when outside of tests.

To allow projects to migrate their existing code over to this new paradigm gradually, we allow this behaviour to be disabled. This was previously controlled by monkey-patching a module scoped value in tests, but is now exposed with a Django setting: SUBATOMIC_RUN_AFTER_COMMIT_CALLBACKS_IN_TESTS.

Fixes #9.

By default, in (non transaction testcase) tests, we simulate the
execution of after-commit callbacks, to reproduce Django's normal
behaviour when outside of tests.

To allow projects to migrate their existing code over to this new
paradigm gradually, we allow this behaviour to be disabled. This was
previously controlled by monkey-patching a module scoped value in tests,
but is now exposed with a Django setting:
`SUBATOMIC_RUN_AFTER_COMMIT_CALLBACKS_IN_TESTS`.

Co-authored-by: Samuel Searles-Bryant <sam.searles-bryant@kraken.tech>
@meshy meshy requested a review from a team as a code owner September 17, 2025 12:06
@meshy meshy merged commit c273985 into main Sep 17, 2025
4 checks passed
@meshy meshy deleted the transaction-callback-simulation-setting branch September 17, 2025 12:13
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.

Expose opt-out mechanism for tests

2 participants

Comments