summaryrefslogtreecommitdiff
path: root/django/test/testcases.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-04 13:12:59 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-11 14:48:54 +0100
commitba5138b1c0253fcf390b7509ad7b954117b3be88 (patch)
tree3643751bf60d04bf39862940242559c1fb0529eb /django/test/testcases.py
parent14aa563f51c1a8a2ece52ca6b9e66aed9c89c0fd (diff)
Deprecated transaction.commit/rollback_unless_managed.
Since "unless managed" now means "if database-level autocommit", committing or rolling back doesn't have any effect. Restored transactional integrity in a few places that relied on automatically-started transactions with a transitory API.
Diffstat (limited to 'django/test/testcases.py')
-rw-r--r--django/test/testcases.py19
1 files changed, 1 insertions, 18 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 4b9116e3bc..55673dca25 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -157,14 +157,6 @@ class DocTestRunner(doctest.DocTestRunner):
doctest.DocTestRunner.__init__(self, *args, **kwargs)
self.optionflags = doctest.ELLIPSIS
- def report_unexpected_exception(self, out, test, example, exc_info):
- doctest.DocTestRunner.report_unexpected_exception(self, out, test,
- example, exc_info)
- # Rollback, in case of database errors. Otherwise they'd have
- # side effects on other tests.
- for conn in connections:
- transaction.rollback_unless_managed(using=conn)
-
class _AssertNumQueriesContext(CaptureQueriesContext):
def __init__(self, test_case, num, connection):
@@ -490,14 +482,10 @@ class TransactionTestCase(SimpleTestCase):
conn.ops.sequence_reset_by_name_sql(no_style(),
conn.introspection.sequence_list())
if sql_list:
- try:
+ with transaction.commit_on_success_unless_managed(using=db_name):
cursor = conn.cursor()
for sql in sql_list:
cursor.execute(sql)
- except Exception:
- transaction.rollback_unless_managed(using=db_name)
- raise
- transaction.commit_unless_managed(using=db_name)
def _fixture_setup(self):
for db_name in self._databases_names(include_mirrors=False):
@@ -537,11 +525,6 @@ class TransactionTestCase(SimpleTestCase):
conn.close()
def _fixture_teardown(self):
- # Roll back any pending transactions in order to avoid a deadlock
- # during flush when TEST_MIRROR is used (#18984).
- for conn in connections.all():
- conn.rollback_unless_managed()
-
for db in self._databases_names(include_mirrors=False):
call_command('flush', verbosity=0, interactive=False, database=db,
skip_validation=True, reset_sequences=False)