Make part_of_a_transaction stricter about callbacks#155
Merged
Conversation
Before this change, after-commit callbacks would pollute the transaction in which tests run, and would sometimes be run by later code. This change wipes the list of after-commit callbacks from the connection before `part_of_a_transaction` completes. Co-authored-by: Lily <code@lilyf.org>
The test util `part_of_a_transaction` didn't raise errors when dangling callbacks were detected in the same way in which `transaction` does. It is now strict in the same way, and shares the same setting to silence the error, `settings.SUBATOMIC_CATCH_UNHANDLED_AFTER_COMMIT_CALLBACKS_IN_TESTS`. Co-authored-by: Lily <code@lilyf.org>
This function can raise an error, but that was not previously documented. Co-authored-by: Lily <code@lilyf.org>
1528006 to
9bd91c6
Compare
LilyFirefly
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are two main improvements here:
part_of_a_transactionwill no longer pollute the test's transaction, and run the risk of being executed later.part_of_a_transactionwill now raise an error if it detects unhandled callbacks when it starts.Fixes #131