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 Dec 2, 2017
1 parent aa45a06 commit 38a959e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,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 38a959e

Please sign in to comment.