Skip to content

Commit

Permalink
fix the assertion error
Browse files Browse the repository at this point in the history
  • Loading branch information
VeldaKiara committed Apr 26, 2024
1 parent a515cc1 commit 4820a9a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
7 changes: 4 additions & 3 deletions debug_toolbar/apps.py
Expand Up @@ -177,7 +177,7 @@ def check_panels(app_configs, **kwargs):
return errors


@register()
@register
def js_mimetype_check(app_configs, **kwargs):
"""
Check that JavaScript files are resolving to the correct content type.
Expand Down Expand Up @@ -208,7 +208,7 @@ def js_mimetype_check(app_configs, **kwargs):
return []


@register()
@register
def debug_toolbar_installed_when_running_tests_check(app_configs, **kwargs):
"""
Check that the toolbar is not being used when tests are running
Expand All @@ -223,13 +223,14 @@ def debug_toolbar_installed_when_running_tests_check(app_configs, **kwargs):
"the toolbar when running tests. If you feel this check is in error, "
"you can set `DEBUG_TOOLBAR_CONFIG['IS_RUNNING_TESTS'] = False` to "
"bypass this check.",
id="debug_toolbar.W008",
id="debug_toolbar.W009",
)
]
else:
return []


@register
def check_settings(app_configs, **kwargs):
errors = []
USER_CONFIG = getattr(settings, "DEBUG_TOOLBAR_CONFIG", {})
Expand Down
2 changes: 2 additions & 0 deletions docs/changes.rst
Expand Up @@ -22,6 +22,8 @@ Pending
``DEBUG_TOOLBAR_SETTINGS``.
* Add a note on the profiling panel about using Python 3.12 and later
about needing ``--nothreading``
* Fixed the bug causing ``'djdt' is not a registered namespace`` and updated
docs to help in initial configuration while running tests.

4.3.0 (2024-02-01)
------------------
Expand Down
17 changes: 5 additions & 12 deletions tests/test_checks.py
Expand Up @@ -101,16 +101,6 @@ def test_panels_is_empty(self):
"settings.py.",
id="debug_toolbar.W005",
),
Error(
"The Django Debug Toolbar can't be used with tests",
hint="Django changes the DEBUG setting to False when running "
"tests. By default the Django Debug Toolbar is installed because "
"DEBUG is set to True. For most cases, you need to avoid installing "
"the toolbar when running tests. If you feel this check is in error, "
"you can set `DEBUG_TOOLBAR_CONFIG['IS_RUNNING_TESTS'] = False` to "
"bypass this check.",
id="debug_toolbar.W008",
),
],
)

Expand Down Expand Up @@ -276,13 +266,16 @@ def test_debug_toolbar_installed_when_running_tests(self):
"the toolbar when running tests. If you feel this check is in error, "
"you can set `DEBUG_TOOLBAR_CONFIG['IS_RUNNING_TESTS'] = False` to "
"bypass this check.",
id="debug_toolbar.W008",
id="debug_toolbar.W009",
)
],
)

@override_settings(
DEBUG_TOOLBAR_CONFIG={"OBSERVE_REQUEST_CALLBACK": lambda request: False}
DEBUG_TOOLBAR_CONFIG={
"OBSERVE_REQUEST_CALLBACK": lambda request: False,
"IS_RUNNING_TESTS": False,
}
)
def test_observe_request_callback_specified(self):
errors = run_checks()
Expand Down

0 comments on commit 4820a9a

Please sign in to comment.