How do you test Django code that uses commit_manually() from a unittest?
I have a long-running method that deletes large numbers of records, enough so that it can't keep all those changes in a single transaction without consuming all system memory. So I wrap it in @commit_manually
and periodically call commit()
.
However, in Django 1.6, all unittests are now wrapped in transaction.atomic()
, so if I try and make any manual commits, I get the error:
django.db.transaction.TransactionManagementError: This is forbidden when an 'atomic' block is active.
What's a work-around for this?