85
def cleanup_db(testcase):
86
# Force a flush of the db: this is called by test classes based on
87
# django.test.TransactionTestCase at the beginning of each
88
# TransactionTestCase test but not at the end. The Django test runner
89
# avoids any problem by running all the TestCase tests and *then*
90
# all the TransactionTestCase tests. Since we use nose, we don't
91
# have that ordering and thus we need to manually flush the db after
92
# each TransactionTestCase test. Le Sigh.
93
if getattr(testcase, 'multi_db', False):
94
databases = connections
96
databases = [DEFAULT_DB_ALIAS]
98
call_command('flush', verbosity=0, interactive=False, database=db)
101
84
class TransactionTestCase(MAASTestCase, django.test.TransactionTestCase):
102
"""`TransactionTestCase` for Metal as a Service.
85
"""`TransactionTestCase` for MAAS.
104
87
A version of MAASTestCase that supports transactions.
106
89
The basic Django TestCase class uses transactions to speed up tests
107
so this class should be used when tests involve transactions.
90
so this class should only be used when tests involve transactions.
109
def _fixture_teardown(self):
111
super(TransactionTestCase, self)._fixture_teardown()
114
94
class TestModelMixin: