

def test_no_transaction_created_when_exception_raised(self):
    user = UserFactory()
    source = AccountFactory(credit_limit=None)
    destination = AccountFactory()
    with mock.patch('oscar_accounts.abstract_models.PostingManager._wrap') as mock_method:
        mock_method.side_effect = RuntimeError()
        try:
            facade.transfer(source, destination, D('100'), user)
        except Exception:
            pass
    self.assertEqual(0, Transfer.objects.all().count())
    self.assertEqual(0, Transaction.objects.all().count())

dataset/ETHPy150Open django-oscar/django-oscar-accounts/tests/unit/facade_tests.py TestErrorHandling.test_no_transaction_created_when_exception_raised/original