1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Added some assertions to enforce the atomicity of atomic.

This commit is contained in:
Aymeric Augustin
2013-03-04 23:26:31 +01:00
parent d7bc4fbc94
commit 7c46c8d5f2
14 changed files with 369 additions and 279 deletions

View File

@@ -25,7 +25,8 @@ class SampleTestCase(TestCase):
class TestNoInitialDataLoading(TransactionTestCase):
def test_syncdb(self):
with transaction.commit_manually():
transaction.set_autocommit(autocommit=False)
try:
Book.objects.all().delete()
management.call_command(
@@ -35,6 +36,9 @@ class TestNoInitialDataLoading(TransactionTestCase):
)
self.assertQuerysetEqual(Book.objects.all(), [])
transaction.rollback()
finally:
transaction.set_autocommit(autocommit=True)
def test_flush(self):
# Test presence of fixture (flush called by TransactionTestCase)
@@ -45,7 +49,8 @@ class TestNoInitialDataLoading(TransactionTestCase):
lambda a: a.name
)
with transaction.commit_manually():
transaction.set_autocommit(autocommit=False)
try:
management.call_command(
'flush',
verbosity=0,
@@ -55,6 +60,8 @@ class TestNoInitialDataLoading(TransactionTestCase):
)
self.assertQuerysetEqual(Book.objects.all(), [])
transaction.rollback()
finally:
transaction.set_autocommit(autocommit=True)
class FixtureTestCase(TestCase):