def test__crashes_on_enter_if_hooks_exist(self):
hook = Deferred()
post_commit_hooks.add(hook)
with ExpectedException(TransactionManagementError):
with post_commit_hooks:
pass
# The hook has been cancelled, but CancelledError is suppressed in
# hooks, so we don't see it here.
self.assertThat(hook, IsFiredDeferred())
# The hook list is cleared so that the exception is raised only once.
self.assertThat(post_commit_hooks.hooks, HasLength(0))
评论列表
文章目录