summaryrefslogtreecommitdiff
path: root/tests/fixtures_model_package
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-07-09 21:12:51 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-07-09 21:41:30 +0200
commit38bc581bc02d83ecab6d19514ac51b57f0e11866 (patch)
tree36ce4e31a1496c36baf7686c28827536c4c06ed5 /tests/fixtures_model_package
parent6157192b6e15ca94734e56be6c71a4154c6015bd (diff)
Avoided transaction.set_autocommit in tests.
It doesn't work as one might expect on a certain database backend where autocommits_when_autocommit_is_off = True. That backend happens to be popular for running tests.
Diffstat (limited to 'tests/fixtures_model_package')
-rw-r--r--tests/fixtures_model_package/tests.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/tests/fixtures_model_package/tests.py b/tests/fixtures_model_package/tests.py
index 4b00e6dfb9..ad82267da3 100644
--- a/tests/fixtures_model_package/tests.py
+++ b/tests/fixtures_model_package/tests.py
@@ -30,8 +30,7 @@ class TestNoInitialDataLoading(TransactionTestCase):
available_apps = ['fixtures_model_package']
def test_syncdb(self):
- transaction.set_autocommit(False)
- try:
+ with transaction.atomic():
Book.objects.all().delete()
management.call_command(
@@ -40,9 +39,6 @@ class TestNoInitialDataLoading(TransactionTestCase):
load_initial_data=False
)
self.assertQuerysetEqual(Book.objects.all(), [])
- transaction.rollback()
- finally:
- transaction.set_autocommit(True)
def test_flush(self):
@@ -54,8 +50,7 @@ class TestNoInitialDataLoading(TransactionTestCase):
lambda a: a.name
)
- transaction.set_autocommit(False)
- try:
+ with transaction.atomic():
management.call_command(
'flush',
verbosity=0,
@@ -63,9 +58,6 @@ class TestNoInitialDataLoading(TransactionTestCase):
load_initial_data=False
)
self.assertQuerysetEqual(Book.objects.all(), [])
- transaction.rollback()
- finally:
- transaction.set_autocommit(True)
class FixtureTestCase(TestCase):