I have a function that I've got wrapped in @transaction.commit_on_success
and running Django unit tests on it.
The function is too long to paste, but some pseudocode is:
@transaction.commit_on_success
def func():
order = Order.create()
order.save()
OrderItem.create(order=order)
test = 10/0 # make sure we run into an error
Then in my unit test I check if len(Order.objects.all()) == 0
My function is returning a valid Order object, so the transaction is committing.
What am I doing wrong here?
EDIT: I'm on Django 1.5