Prevented TestNoInitialDataLoading to pollute other tests (Refs #15926)
Tests were still failing with MySQL. It seems a rollback is solving the issue.
This commit is contained in:
parent
f5ce1793a8
commit
2c57809a56
@ -1,5 +1,6 @@
|
|||||||
from django.core import management
|
from django.core import management
|
||||||
from django.test import TestCase
|
from django.db import transaction
|
||||||
|
from django.test import TestCase, TransactionTestCase
|
||||||
|
|
||||||
from .models import Article, Book
|
from .models import Article, Book
|
||||||
|
|
||||||
@ -20,16 +21,18 @@ class SampleTestCase(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestNoInitialDataLoading(TestCase):
|
class TestNoInitialDataLoading(TransactionTestCase):
|
||||||
def test_syncdb(self):
|
def test_syncdb(self):
|
||||||
Book.objects.all().delete()
|
with transaction.commit_manually():
|
||||||
|
Book.objects.all().delete()
|
||||||
|
|
||||||
management.call_command(
|
management.call_command(
|
||||||
'syncdb',
|
'syncdb',
|
||||||
verbosity=0,
|
verbosity=0,
|
||||||
load_initial_data=False
|
load_initial_data=False
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(Book.objects.all(), [])
|
self.assertQuerysetEqual(Book.objects.all(), [])
|
||||||
|
transaction.rollback()
|
||||||
|
|
||||||
def test_flush(self):
|
def test_flush(self):
|
||||||
# Test presence of fixture (flush called by TransactionTestCase)
|
# Test presence of fixture (flush called by TransactionTestCase)
|
||||||
@ -40,13 +43,16 @@ class TestNoInitialDataLoading(TestCase):
|
|||||||
lambda a: a.name
|
lambda a: a.name
|
||||||
)
|
)
|
||||||
|
|
||||||
management.call_command(
|
with transaction.commit_manually():
|
||||||
'flush',
|
management.call_command(
|
||||||
verbosity=0,
|
'flush',
|
||||||
interactive=False,
|
verbosity=0,
|
||||||
load_initial_data=False
|
interactive=False,
|
||||||
)
|
commit=False,
|
||||||
self.assertQuerysetEqual(Book.objects.all(), [])
|
load_initial_data=False
|
||||||
|
)
|
||||||
|
self.assertQuerysetEqual(Book.objects.all(), [])
|
||||||
|
transaction.rollback()
|
||||||
|
|
||||||
|
|
||||||
class FixtureTestCase(TestCase):
|
class FixtureTestCase(TestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user