summaryrefslogtreecommitdiff
path: root/tests/backends
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-04 23:26:31 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-11 14:48:55 +0100
commit7c46c8d5f27fe305507359588ca0635b6d87c59a (patch)
treeca99a91cedfd6d8d03a3fbe334ee9589a51ef002 /tests/backends
parentd7bc4fbc94df6c231d71dffa45cf337ff13512ee (diff)
Added some assertions to enforce the atomicity of atomic.
Diffstat (limited to 'tests/backends')
-rw-r--r--tests/backends/tests.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 5c8a8955eb..51acbcb07f 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -522,7 +522,8 @@ class FkConstraintsTests(TransactionTestCase):
"""
When constraint checks are disabled, should be able to write bad data without IntegrityErrors.
"""
- with transaction.commit_manually():
+ transaction.set_autocommit(autocommit=False)
+ try:
# 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
@@ -536,12 +537,15 @@ class FkConstraintsTests(TransactionTestCase):
self.fail("IntegrityError should not have occurred.")
finally:
transaction.rollback()
+ finally:
+ transaction.set_autocommit(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.
"""
- with transaction.commit_manually():
+ transaction.set_autocommit(autocommit=False)
+ try:
# 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
@@ -554,12 +558,15 @@ class FkConstraintsTests(TransactionTestCase):
self.fail("IntegrityError should not have occurred.")
finally:
transaction.rollback()
+ finally:
+ transaction.set_autocommit(autocommit=True)
def test_check_constraints(self):
"""
Constraint checks should raise an IntegrityError when bad data is in the DB.
"""
- with transaction.commit_manually():
+ try:
+ transaction.set_autocommit(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
@@ -572,6 +579,8 @@ class FkConstraintsTests(TransactionTestCase):
connection.check_constraints()
finally:
transaction.rollback()
+ finally:
+ transaction.set_autocommit(autocommit=True)
class ThreadTests(TestCase):