from StringIO import StringIO
from django.core.management import call_command
import pytest


def test_for_missing_migrations():
    output = StringIO()
    try:
        call_command(
            'makemigrations', interactive=False, dry_run=True, exit_code=True,
            stdout=output)
    except SystemExit as e:
        # The exit code will be 1 when there are no missing migrations
        assert unicode(e) == '1'
    else:
        pytest.fail("There are missing migrations:\n %s" % output.getvalue())

Add test to fail if there are migrations missing.
Add test to fail if there are migrations missing.
