Skip to content

Commit 7b34c28

Browse files
authored
Mock out migrate.Command with --no-migrations (#729)
It would still add some overhead (especially with regard to output noise).
1 parent 8e6eafe commit 7b34c28

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pytest_django/fixtures.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,17 @@ class ResetSequenceTestCase(django_case):
155155

156156
def _disable_native_migrations():
157157
from django.conf import settings
158+
from django.core.management.commands.migrate import Command
159+
158160
from .migrations import DisableMigrations
159161

160162
settings.MIGRATION_MODULES = DisableMigrations()
161163

164+
def migrate_noop(self, *args, **kwargs):
165+
pass
166+
167+
Command.handle = migrate_noop
168+
162169

163170
# ############### User visible fixtures ################
164171

tests/test_db_setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,10 @@ def test_inner_migrations():
340340
)
341341

342342
result = django_testdir.runpytest_subprocess(
343-
"--nomigrations", "--tb=short", "-v"
343+
"--nomigrations", "--tb=short", "-vv",
344344
)
345345
assert result.ret == 0
346+
assert "Operations to perform:" not in result.stdout.str()
346347
result.stdout.fnmatch_lines(["*test_inner_migrations*PASSED*"])
347348

348349
def test_migrations_run(self, django_testdir):

0 commit comments

Comments
 (0)