File tree Expand file tree Collapse file tree 5 files changed +40
-4
lines changed Expand file tree Collapse file tree 5 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 1414 hooks :
1515 - id : doc8
1616- repo : https://github.com/adamchainz/django-upgrade
17- rev : 1.24 .0
17+ rev : 1.25 .0
1818 hooks :
1919 - id : django-upgrade
2020 args : [--target-version, "4.2"]
@@ -29,12 +29,12 @@ repos:
2929 - id : rst-backticks
3030 - id : rst-directive-colons
3131- repo : https://github.com/biomejs/pre-commit
32- rev : v2.0.0-beta.3
32+ rev : v2.0.0-beta.4
3333 hooks :
3434 - id : biome-check
3535 verbose : true
3636- repo : https://github.com/astral-sh/ruff-pre-commit
37- rev : ' v0.11.9 '
37+ rev : ' v0.11.10 '
3838 hooks :
3939 - id : ruff
4040 args : [--fix, --exit-non-zero-on-fix]
Original file line number Diff line number Diff line change 3838 "useExportType" : " error" ,
3939 "noUselessElse" : " error" ,
4040 "useShorthandFunctionType" : " error"
41+ },
42+ "suspicious" : {
43+ "noDocumentCookie" : " off"
4144 }
4245 }
4346 },
Original file line number Diff line number Diff line change 77from django .dispatch import receiver
88from django .test .signals import setting_changed
99
10+
11+ def _is_running_tests ():
12+ """
13+ Helper function to support testing default value for
14+ IS_RUNNING_TESTS
15+ """
16+ return "test" in sys .argv or "PYTEST_VERSION" in os .environ
17+
18+
1019CONFIG_DEFAULTS = {
1120 # Toolbar options
1221 "DISABLE_PANELS" : {
4554 "OBSERVE_REQUEST_CALLBACK" : "debug_toolbar.toolbar.observe_request" ,
4655 "TOOLBAR_LANGUAGE" : None ,
4756 "TOOLBAR_STORE_CLASS" : "debug_toolbar.store.MemoryStore" ,
48- "IS_RUNNING_TESTS" : "test" in sys . argv or "PYTEST_VERSION" in os . environ ,
57+ "IS_RUNNING_TESTS" : _is_running_tests () ,
4958 "UPDATE_ON_FETCH" : False ,
5059}
5160
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ psycopg
4949py
5050pyflame
5151pylibmc
52+ pytest
5253pyupgrade
5354querysets
5455refactoring
@@ -65,5 +66,6 @@ theming
6566timeline
6667tox
6768uWSGI
69+ unhandled
6870unhashable
6971validator
Original file line number Diff line number Diff line change 1+ from unittest .mock import patch
2+
3+ from django .test import TestCase
4+
5+ from debug_toolbar .settings import _is_running_tests
6+
7+
8+ class SettingsTestCase (TestCase ):
9+ @patch ("debug_toolbar.settings.sys" )
10+ @patch ("debug_toolbar.settings.os" )
11+ def test_is_running_tests (self , mock_os , mock_sys ):
12+ mock_sys .argv = "test"
13+ mock_os .environ = {}
14+ self .assertTrue (_is_running_tests ())
15+
16+ mock_sys .argv = ""
17+ mock_os .environ = {}
18+ self .assertFalse (_is_running_tests ())
19+
20+ mock_sys .argv = ""
21+ mock_os .environ = {"PYTEST_VERSION" : "1" }
22+ self .assertTrue (_is_running_tests ())
You can’t perform that action at this time.
0 commit comments