mirror of
https://github.com/django/django.git
synced 2025-11-24 21:00:12 +00:00
Improved the API of set_autocommit.
This commit is contained in:
parent
f32100939e
commit
e654180ce2
8 changed files with 24 additions and 24 deletions
|
|
@ -522,7 +522,7 @@ class FkConstraintsTests(TransactionTestCase):
|
|||
"""
|
||||
When constraint checks are disabled, should be able to write bad data without IntegrityErrors.
|
||||
"""
|
||||
transaction.set_autocommit(autocommit=False)
|
||||
transaction.set_autocommit(False)
|
||||
try:
|
||||
# Create an Article.
|
||||
models.Article.objects.create(headline="Test article", pub_date=datetime.datetime(2010, 9, 4), reporter=self.r)
|
||||
|
|
@ -538,13 +538,13 @@ class FkConstraintsTests(TransactionTestCase):
|
|||
finally:
|
||||
transaction.rollback()
|
||||
finally:
|
||||
transaction.set_autocommit(autocommit=True)
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
def test_disable_constraint_checks_context_manager(self):
|
||||
"""
|
||||
When constraint checks are disabled (using context manager), should be able to write bad data without IntegrityErrors.
|
||||
"""
|
||||
transaction.set_autocommit(autocommit=False)
|
||||
transaction.set_autocommit(False)
|
||||
try:
|
||||
# Create an Article.
|
||||
models.Article.objects.create(headline="Test article", pub_date=datetime.datetime(2010, 9, 4), reporter=self.r)
|
||||
|
|
@ -559,14 +559,14 @@ class FkConstraintsTests(TransactionTestCase):
|
|||
finally:
|
||||
transaction.rollback()
|
||||
finally:
|
||||
transaction.set_autocommit(autocommit=True)
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
def test_check_constraints(self):
|
||||
"""
|
||||
Constraint checks should raise an IntegrityError when bad data is in the DB.
|
||||
"""
|
||||
try:
|
||||
transaction.set_autocommit(autocommit=False)
|
||||
transaction.set_autocommit(False)
|
||||
# Create an Article.
|
||||
models.Article.objects.create(headline="Test article", pub_date=datetime.datetime(2010, 9, 4), reporter=self.r)
|
||||
# Retrive it from the DB
|
||||
|
|
@ -580,7 +580,7 @@ class FkConstraintsTests(TransactionTestCase):
|
|||
finally:
|
||||
transaction.rollback()
|
||||
finally:
|
||||
transaction.set_autocommit(autocommit=True)
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
|
||||
class ThreadTests(TestCase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue