Skip to content

Instantly share code, notes, and snippets.

@jkeyes
Created October 3, 2012 23:10
Show Gist options
  • Save jkeyes/3830479 to your computer and use it in GitHub Desktop.
Save jkeyes/3830479 to your computer and use it in GitHub Desktop.
Standalone functions to disable and restore Django transaction support
from django.db import connections
from django.db import transaction
def disable_transaction_methods():
from django.test.testcases import disable_transaction_methods
for db in connections:
transaction.enter_transaction_management(using=db)
transaction.managed(True, using=db)
disable_transaction_methods()
def restore_transaction_methods():
from django.test.testcases import restore_transaction_methods
restore_transaction_methods()
for db in connections:
transaction.rollback(using=db)
transaction.leave_transaction_management(using=db)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment