def test_on_signal__no_transaction(self, partial, on_commit):
# test with signal_honor_transaction and not in transaction
event = self.mock_event('x.y', sender_field=None)
event.signal_honors_transaction = True
event._on_signal = Mock(name='_on_signal')
instance = self.Model()
on_commit.side_effect = TransactionManagementError()
assert django.TransactionManagementError is TransactionManagementError
event.on_signal(instance, kw=1)
partial.assert_called_once_with(event._on_signal, instance, {'kw': 1})
on_commit.assert_called_once_with(partial())
partial.return_value.assert_called_once_with()
评论列表
文章目录