Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thisboyiscrazy/5503169 to your computer and use it in GitHub Desktop.
Save thisboyiscrazy/5503169 to your computer and use it in GitHub Desktop.
A class for django nose testing that work with test generators and also uses transations
from django.db import transaction
from django.test.testcases import disable_transaction_methods, restore_transaction_methods
from django.core import mail
class TransactionTest(object):
def setUp(self):
transaction.enter_transaction_management()
transaction.managed(True)
disable_transaction_methods()
mail.outbox = []
def tearDown(self):
restore_transaction_methods()
transaction.rollback()
transaction.leave_transaction_management()
mail.outbox = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment