Commit 2c57809a authored by Claude Paroz's avatar Claude Paroz
Browse files

Prevented TestNoInitialDataLoading to pollute other tests (Refs #15926)

Tests were still failing with MySQL. It seems a rollback is solving
the issue.
parent f5ce1793
Loading
Loading
Loading
Loading
+22 −16
Original line number Diff line number Diff line
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

@@ -20,8 +21,9 @@ class SampleTestCase(TestCase):
        )


class TestNoInitialDataLoading(TestCase):
class TestNoInitialDataLoading(TransactionTestCase):
    def test_syncdb(self):
        with transaction.commit_manually():
            Book.objects.all().delete()

            management.call_command(
@@ -30,6 +32,7 @@ class TestNoInitialDataLoading(TestCase):
                load_initial_data=False
            )
            self.assertQuerysetEqual(Book.objects.all(), [])
            transaction.rollback()

    def test_flush(self):
        # Test presence of fixture (flush called by TransactionTestCase)
@@ -40,13 +43,16 @@ class TestNoInitialDataLoading(TestCase):
            lambda a: a.name
        )

        with transaction.commit_manually():
            management.call_command(
                'flush',
                verbosity=0,
                interactive=False,
                commit=False,
                load_initial_data=False
            )
            self.assertQuerysetEqual(Book.objects.all(), [])
            transaction.rollback()


class FixtureTestCase(TestCase):