Skip to content

Update setup_databases call to handle >3.1 #859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pytest_django/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ def teardown_databases(db_cfg, verbosity):
_DiscoverRunner(verbosity=verbosity, interactive=False).teardown_databases(
db_cfg
)


# Import NullTimeKeeper from Django > 3.1 for setup_databases call -
# fix for https://github.com/pytest-dev/pytest-django/issues/858
try:
from django.test.utils import NullTimeKeeper
setup_databases_args = {"time_keeper": NullTimeKeeper()}
except ImportError:
setup_databases_args = {}
4 changes: 1 addition & 3 deletions pytest_django/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ def django_db_setup(
django_db_modify_db_settings,
):
"""Top level fixture to ensure test databases are available"""
from .compat import setup_databases, teardown_databases

setup_databases_args = {}
from .compat import setup_databases, teardown_databases, setup_databases_args

if not django_db_use_migrations:
_disable_native_migrations()
Expand Down