Skip to content

Commit

Permalink
Follow the new convention for Django 11.0
Browse files Browse the repository at this point in the history
a new option --debug-mode has been introduced, so let's name ours
--django-debug-mode
  • Loading branch information
dulacp committed Dec 2, 2017
1 parent a63d216 commit 2c9bc28
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Unreleased
Features
^^^^^^^^

* Added a new option `--django-debug` to specify the default DEBUG setting (#228)
* Added a new option `--django-debug-mode` to specify the default DEBUG setting (#228)

3.1.2
-----
Expand Down
2 changes: 1 addition & 1 deletion docs/configuring_django.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ But sometimes, especially for functional tests, you might want to avoid this, to

Command Line Option::

$ py.test --django-debug True|False|None
$ py.test --django-debug-mode True|False|None

``None`` ensure there is no override of the test settings DEBUG value
``True`` override DEBUG to True
Expand Down
8 changes: 4 additions & 4 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def pytest_addoption(parser):
group._addoption('--migrations',
action='store_false', dest='nomigrations', default=False,
help='Enable Django migrations on test setup')
group._addoption('--django-debug',
action='store', dest='djangodebug', default='False',
group._addoption('--django-debug-mode',
action='store', dest='djangodebugmode', default='False',
help='Configure the DEBUG setting. Defaults to False')
parser.addini(CONFIGURATION_ENV,
'django-configurations class to use by pytest-django.')
Expand Down Expand Up @@ -339,8 +339,8 @@ def django_test_environment(request):
from django.conf import settings as dj_settings
from django.test.utils import (setup_test_environment,
teardown_test_environment)
if request.config.getvalue('djangodebug') != 'None':
dj_settings.DEBUG = bool(strtobool(request.config.getvalue('djangodebug')))
if request.config.getvalue('djangodebugmode') != 'None':
dj_settings.DEBUG = bool(strtobool(request.config.getvalue('djangodebugmode')))
setup_test_environment()
request.addfinalizer(teardown_test_environment)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_django_settings_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_debug_is_unchanged():
assert settings.DEBUG is True
""")

r = testdir.runpytest_subprocess('--django-debug=None')
r = testdir.runpytest_subprocess('--django-debug-mode=None')
assert r.ret == 0


Expand All @@ -321,7 +321,7 @@ def test_debug_is_false():
assert settings.DEBUG is False
""")

r = testdir.runpytest_subprocess('--django-debug=False')
r = testdir.runpytest_subprocess('--django-debug-mode=False')
assert r.ret == 0


Expand All @@ -346,7 +346,7 @@ def test_debug_is_true():
assert settings.DEBUG is True
""")

r = testdir.runpytest_subprocess('--django-debug=True')
r = testdir.runpytest_subprocess('--django-debug-mode=True')
assert r.ret == 0


Expand Down

0 comments on commit 2c9bc28

Please sign in to comment.