File: test_fixtures_migrations.py

package info (click to toggle)
python-pytest-djangoapp 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 396 kB
  • sloc: python: 1,116; makefile: 114; sh: 6
file content (25 lines) | stat: -rw-r--r-- 892 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import re
import pytest

from django import VERSION


@pytest.mark.skipif(VERSION < (2, 0), reason='Django 2.0+ required')
def test_check_migrations_missing(check_migrations):
    result = check_migrations('testapp_missing_migrations')
    assert result is False, 'Migrations should be missing in testapp_missing_migrations'


@pytest.mark.skipif(VERSION < (2, 0), reason='Django 2.0+ required')
def test_check_migrations_ok(check_migrations):
    result = check_migrations()
    assert result, (
        "ERROR: Migrations check failed! Models' changes not migrated, "
        "please run './manage.py makemigrations' to solve the issue!"
    )


@pytest.mark.skipif(VERSION >= (2, 0), reason='Testing Django 1.9- required')
def test_old_django(check_migrations):
    with pytest.raises(Exception, match=re.escape('Django 2.0+ required for checking migrations')):
        check_migrations()