Fixed isolation of NonAutocommitTests.test_orm_query_after_error_and_rollback().
This commit is contained in:
parent
7bb0605a8c
commit
ae32e337e0
|
@ -477,12 +477,18 @@ class NonAutocommitTests(TransactionTestCase):
|
||||||
|
|
||||||
available_apps = []
|
available_apps = []
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
transaction.set_autocommit(False)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
transaction.rollback()
|
||||||
|
transaction.set_autocommit(True)
|
||||||
|
|
||||||
def test_orm_query_after_error_and_rollback(self):
|
def test_orm_query_after_error_and_rollback(self):
|
||||||
"""
|
"""
|
||||||
ORM queries are allowed after an error and a rollback in non-autocommit
|
ORM queries are allowed after an error and a rollback in non-autocommit
|
||||||
mode (#27504).
|
mode (#27504).
|
||||||
"""
|
"""
|
||||||
transaction.set_autocommit(False)
|
|
||||||
r1 = Reporter.objects.create(first_name='Archibald', last_name='Haddock')
|
r1 = Reporter.objects.create(first_name='Archibald', last_name='Haddock')
|
||||||
r2 = Reporter(first_name='Cuthbert', last_name='Calculus', id=r1.id)
|
r2 = Reporter(first_name='Cuthbert', last_name='Calculus', id=r1.id)
|
||||||
with self.assertRaises(IntegrityError):
|
with self.assertRaises(IntegrityError):
|
||||||
|
@ -492,12 +498,7 @@ class NonAutocommitTests(TransactionTestCase):
|
||||||
|
|
||||||
def test_orm_query_without_autocommit(self):
|
def test_orm_query_without_autocommit(self):
|
||||||
"""#24921 -- ORM queries must be possible after set_autocommit(False)."""
|
"""#24921 -- ORM queries must be possible after set_autocommit(False)."""
|
||||||
transaction.set_autocommit(False)
|
Reporter.objects.create(first_name="Tintin")
|
||||||
try:
|
|
||||||
Reporter.objects.create(first_name="Tintin")
|
|
||||||
finally:
|
|
||||||
transaction.rollback()
|
|
||||||
transaction.set_autocommit(True)
|
|
||||||
|
|
||||||
|
|
||||||
class DurableTests(TransactionTestCase):
|
class DurableTests(TransactionTestCase):
|
||||||
|
|
Loading…
Reference in New Issue