Skip to content

Commit

Permalink
Get database blocker from Config.stash (#51)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Iuri de Silvio <[email protected]>
  • Loading branch information
walison17 and iurisilvio authored Feb 7, 2024
1 parent 190bf83 commit c7e786b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/example-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dist/
*.sqlite3
coverage*.xml
poetry.lock
.venv/
10 changes: 7 additions & 3 deletions django_migrations_ci/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from io import StringIO
from unittest.mock import sentinel

import django as djangoframework
Expand Down

0 comments on commit c7e786b

Please sign in to comment.