diff --git a/.github/workflows/example-test.yml b/.github/workflows/example-test.yml index 36642e9..3b76360 100644 --- a/.github/workflows/example-test.yml +++ b/.github/workflows/example-test.yml @@ -22,6 +22,7 @@ jobs: fail-fast: false matrix: python-version: ["3.10", "3.11", "3.12"] + pytest-django: ["<4.7", ">=4.7"] steps: - uses: actions/checkout@v3 @@ -35,6 +36,7 @@ jobs: python -m pip install --upgrade pip python -m pip install -r requirements.txt python -m pip install .. + python -m pip install "pytest-django${{ matrix.pytest-django }}" - name: Django migrate run: | ./manage.py migrateci -v3 --parallel 2 diff --git a/.gitignore b/.gitignore index 3c2318d..509e271 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ dist/ *.sqlite3 coverage*.xml poetry.lock +.venv/ diff --git a/django_migrations_ci/pytest_plugin.py b/django_migrations_ci/pytest_plugin.py index 69fc8fc..c9d625a 100644 --- a/django_migrations_ci/pytest_plugin.py +++ b/django_migrations_ci/pytest_plugin.py @@ -31,11 +31,15 @@ def pytest_configure(config): return try: - from pytest_django.plugin import _blocking_manager + from pytest_django import plugin - db_unblock = _blocking_manager.unblock + db_unblock = config.stash[plugin.blocking_manager_key].unblock + except AttributeError: + # pytest-django<4.7 doesn't have `blocking_manager_key` defined, + # raising `AttributeError`. + db_unblock = plugin._blocking_manager.unblock except ImportError: - # The pytest-django lib is not installed, do nothing and hope for the best. + # pytest-django lib is not installed, do nothing and hope for the best. db_unblock = nullcontext verbosity = config.option.migrateci_verbose diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index df2bc55..31ec440 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -1,5 +1,4 @@ import os -from io import StringIO from unittest.mock import sentinel import django as djangoframework