mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Used addCleanup() in tests where appropriate.
This commit is contained in:
@@ -259,12 +259,10 @@ class AtomicWithoutAutocommitTests(AtomicTests):
|
||||
|
||||
def setUp(self):
|
||||
transaction.set_autocommit(False)
|
||||
|
||||
def tearDown(self):
|
||||
self.addCleanup(transaction.set_autocommit, True)
|
||||
# The tests access the database after exercising 'atomic', initiating
|
||||
# a transaction ; a rollback is required before restoring autocommit.
|
||||
transaction.rollback()
|
||||
transaction.set_autocommit(True)
|
||||
self.addCleanup(transaction.rollback)
|
||||
|
||||
|
||||
@skipUnlessDBFeature("uses_savepoints")
|
||||
@@ -512,10 +510,8 @@ class NonAutocommitTests(TransactionTestCase):
|
||||
|
||||
def setUp(self):
|
||||
transaction.set_autocommit(False)
|
||||
|
||||
def tearDown(self):
|
||||
transaction.rollback()
|
||||
transaction.set_autocommit(True)
|
||||
self.addCleanup(transaction.set_autocommit, True)
|
||||
self.addCleanup(transaction.rollback)
|
||||
|
||||
def test_orm_query_after_error_and_rollback(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user