Repository: businho/django-migrations-ci (language: python)

Issue:
Last changes in pytest-django makes django-migrations-ci not compatible
The way of pytest-django config is changed, and [django-migrations-ci](https://github.com/businho/django-migrations-ci) pytest plugin detection at https://github.com/businho/django-migrations-ci/blob/bc19219611031a8967423367a345b931423fe516/django_migrations_ci/pytest_plugin.py#L33-L37 not work anymore.

Changed lines:

https://github.com/pytest-dev/pytest-django/compare/v4.6.0...v4.7.0#diff-120a0c7749b191d7a49ee491cb042bf5952a09689a31802bebc88fba3ca94c98L802-L803


Discussion / hints:

Fix patch:
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/


Test patch:
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/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