mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #26627 -- Fixed on_commit callbacks execution order when callbacks make transactions.
This commit is contained in:
parent
4ff1e6ef58
commit
a5c8072ab1
3 changed files with 22 additions and 6 deletions
|
@ -208,6 +208,20 @@ class TestConnectionOnCommit(TransactionTestCase):
|
|||
|
||||
self.assertDone([1])
|
||||
|
||||
def test_hook_in_hook(self):
|
||||
def on_commit(i, add_hook):
|
||||
with transaction.atomic():
|
||||
if add_hook:
|
||||
transaction.on_commit(lambda: on_commit(i + 10, False))
|
||||
t = Thing.objects.create(num=i)
|
||||
self.notify(t.num)
|
||||
|
||||
with transaction.atomic():
|
||||
transaction.on_commit(lambda: on_commit(1, True))
|
||||
transaction.on_commit(lambda: on_commit(2, True))
|
||||
|
||||
self.assertDone([1, 11, 2, 12])
|
||||
|
||||
def test_raises_exception_non_autocommit_mode(self):
|
||||
def should_never_be_called():
|
||||
raise AssertionError('this function should never be called')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue