neubloc/django-colortools — pull request #2 by zenoamaro (2013-12-18 16:46:13+00:00)
Title: Wrapped tests now make use of Django's atomic transactions

This patch updates `ColorDjangoTestSuiteRunner.wrap_tests` in order to use
of Django's atomic transactions, as well as making them available to the
`TestCase` itself.

These are the parts that needed to be backported from Django:

# django/test/testcases.py:848
# https://github.com/django/django/blob/master/django/test/testcases.py#L848
def _fixture_setup(self):
# ...
self.atomics = {}
for db_name in self._databases_names():
self.atomics[db_name] = transaction.atomic(using=db_name)
self.atomics[db_name].__enter__()
# ...

# django/test/testcases.py:877
# https://github.com/django/django/blob/master/django/test/testcases.py#L877
def _fixture_teardown(self):
# ...
for db_name in reversed(self._databases_names()):
# ...
self.atomics[db_name].__exit__(None, None, None)