Disallow nesting part_of_a_transaction#153
Merged
Merged
Conversation
part_of_a_transactionpart_of_a_transaction
`subatomic.test.part_of_a_transaction` is part of the distributed package, and part of the public API, so it should be tested. Co-authored-by: Jiahao Ren <gl6532575@gmail.com>
c9d1a20 to
e1d62f5
Compare
meshy
commented
May 1, 2026
LilyFirefly
approved these changes
May 1, 2026
Collaborator
LilyFirefly
left a comment
There was a problem hiding this comment.
Looks good to me, as long as my understanding of why durable=True is appropriate in a test is accurate.
| use [`transaction`][django_subatomic.db.transaction] instead. | ||
| """ | ||
| with transaction.atomic(using=using): | ||
| with transaction.atomic(using=using, durable=True): |
Collaborator
There was a problem hiding this comment.
This is safe because Django has something built-in to detect and disregard the testcase transaction here too, right?
Collaborator
Author
There was a problem hiding this comment.
Yes that's right -- Django checks to see if the innermost atomic block is created by a testcase before it complains about nested durable blocks.
Add durable=True to the atomic call inside part_of_a_transaction so that nesting is explicitly disallowed. This prevents tests from looking like they nest partial-transaction behaviour, which does not reflect real-world usage. Fixes #150 Co-authored-by: Charlie Denton <charlie@meshy.co.uk>
e1d62f5 to
d436d0b
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.
Just as it doesn't make sense for transactions to be nested, it doesn't make sense for tests to simulate nesting of parts of transactions.
This fixes #150 and is a rework of #152. In acknowledgement on the reworked commits, I have listed the commits as co-authored with @Giggitycountless.