summaryrefslogtreecommitdiff
path: root/tests/transaction_hooks
diff options
context:
space:
mode:
authorBarthelemy Dagenais <barthelemy@infobart.com>2016-05-17 10:54:57 -0400
committerTim Graham <timograham@gmail.com>2016-05-18 09:09:48 -0400
commita5c8072ab1e56da368a40f3e9c9a3b465f4ffbae (patch)
tree23787132f542d1d97a56d378de80ebb20e38efc6 /tests/transaction_hooks
parent4ff1e6ef58999f730db26ab97e233589c6be9b4f (diff)
downloaddjango-a5c8072ab1e56da368a40f3e9c9a3b465f4ffbae.tar.gz
Fixed #26627 -- Fixed on_commit callbacks execution order when callbacks make transactions.
Diffstat (limited to 'tests/transaction_hooks')
-rw-r--r--tests/transaction_hooks/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/transaction_hooks/tests.py b/tests/transaction_hooks/tests.py
index ebf07bc656..000de4104c 100644
--- a/tests/transaction_hooks/tests.py
+++ b/tests/transaction_hooks/tests.py
@@ -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')