Last active
June 29, 2023 14:25
-
-
Save adamchainz/5b2cdac99c819e6017b7097320536b43 to your computer and use it in GitHub Desktop.
Django test for pending migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from io import StringIO | |
from django.core.management import call_command | |
from django.test import TestCase | |
class PendingMigrationsTests(TestCase): | |
def test_no_pending_migrations(self): | |
out = StringIO() | |
try: | |
call_command( | |
"makemigrations", | |
"--dry-run", | |
"--check", | |
stdout=out, | |
stderr=StringIO(), | |
) | |
except SystemExit: # pragma: no cover | |
raise AssertionError( | |
"Pending migrations:\n" + out.getvalue() | |
) from None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment