Skip to content

Commit

Permalink
Use the Django 1.11 setup api if available
Browse files Browse the repository at this point in the history
  • Loading branch information
dulacp committed May 24, 2019
1 parent 36c9a0d commit 5b4baa1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pytest_django/plugin.py
Expand Up @@ -471,13 +471,21 @@ def django_test_environment(request):
"""
if django_settings_is_configured():
_setup_django()
from distutils.version import StrictVersion
import django
from django.conf import settings as dj_settings
from django.test.utils import setup_test_environment, teardown_test_environment

if request.config.getvalue('djangodebugmode') != 'None':
dj_settings.DEBUG = bool(strtobool(request.config.getvalue('djangodebugmode')))

setup_test_environment()
django_debug_mode = bool(strtobool(request.config.getvalue('djangodebugmode')))
if StrictVersion(django.get_version()) >= StrictVersion('1.11'):
setup_test_environment(debug=django_debug_mode)
else:
dj_settings.DEBUG = django_debug_mode
setup_test_environment()
else:
# default setup
setup_test_environment()
request.addfinalizer(teardown_test_environment)


Expand Down

0 comments on commit 5b4baa1

Please sign in to comment.