diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py index 0c8606f26..94d77dd24 100644 --- a/pytest_django/fixtures.py +++ b/pytest_django/fixtures.py @@ -155,16 +155,18 @@ class ResetSequenceTestCase(django_case): def _disable_native_migrations(): from django.conf import settings - from django.core.management.commands.migrate import Command + from django.core.management.commands import migrate from .migrations import DisableMigrations settings.MIGRATION_MODULES = DisableMigrations() - def migrate_noop(self, *args, **kwargs): - pass + class MigrateSilentCommand(migrate.Command): + def handle(self, *args, **kwargs): + kwargs["verbosity"] = 0 + return super(MigrateSilentCommand, self).handle(*args, **kwargs) - Command.handle = migrate_noop + migrate.Command = MigrateSilentCommand # ############### User visible fixtures ################ diff --git a/tests/test_db_setup.py b/tests/test_db_setup.py index de64c793e..2ce4b6430 100644 --- a/tests/test_db_setup.py +++ b/tests/test_db_setup.py @@ -327,7 +327,8 @@ def test_no_migrations(self, django_testdir): @pytest.mark.django_db def test_inner_migrations(): - pass + from .app.models import Item + Item.objects.create() """ ) @@ -340,11 +341,11 @@ def test_inner_migrations(): ) result = django_testdir.runpytest_subprocess( - "--nomigrations", "--tb=short", "-vv", + "--nomigrations", "--tb=short", "-vv", "-s", ) assert result.ret == 0 assert "Operations to perform:" not in result.stdout.str() - result.stdout.fnmatch_lines(["*test_inner_migrations*PASSED*"]) + result.stdout.fnmatch_lines(["*= 1 passed in *"]) def test_migrations_run(self, django_testdir): testdir = django_testdir @@ -354,7 +355,8 @@ def test_migrations_run(self, django_testdir): @pytest.mark.django_db def test_inner_migrations(): - pass + from .app.models import Item + Item.objects.create() """ )