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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user