File tree 5 files changed +40
-4
lines changed 5 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 14
14
hooks :
15
15
- id : doc8
16
16
- repo : https://github.com/adamchainz/django-upgrade
17
- rev : 1.24 .0
17
+ rev : 1.25 .0
18
18
hooks :
19
19
- id : django-upgrade
20
20
args : [--target-version, "4.2"]
@@ -29,12 +29,12 @@ repos:
29
29
- id : rst-backticks
30
30
- id : rst-directive-colons
31
31
- repo : https://github.com/biomejs/pre-commit
32
- rev : v2.0.0-beta.3
32
+ rev : v2.0.0-beta.4
33
33
hooks :
34
34
- id : biome-check
35
35
verbose : true
36
36
- repo : https://github.com/astral-sh/ruff-pre-commit
37
- rev : ' v0.11.9 '
37
+ rev : ' v0.11.10 '
38
38
hooks :
39
39
- id : ruff
40
40
args : [--fix, --exit-non-zero-on-fix]
Original file line number Diff line number Diff line change 38
38
"useExportType" : " error" ,
39
39
"noUselessElse" : " error" ,
40
40
"useShorthandFunctionType" : " error"
41
+ },
42
+ "suspicious" : {
43
+ "noDocumentCookie" : " off"
41
44
}
42
45
}
43
46
},
Original file line number Diff line number Diff line change 7
7
from django .dispatch import receiver
8
8
from django .test .signals import setting_changed
9
9
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
+
10
19
CONFIG_DEFAULTS = {
11
20
# Toolbar options
12
21
"DISABLE_PANELS" : {
45
54
"OBSERVE_REQUEST_CALLBACK" : "debug_toolbar.toolbar.observe_request" ,
46
55
"TOOLBAR_LANGUAGE" : None ,
47
56
"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 () ,
49
58
"UPDATE_ON_FETCH" : False ,
50
59
}
51
60
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ psycopg
49
49
py
50
50
pyflame
51
51
pylibmc
52
+ pytest
52
53
pyupgrade
53
54
querysets
54
55
refactoring
@@ -65,5 +66,6 @@ theming
65
66
timeline
66
67
tox
67
68
uWSGI
69
+ unhandled
68
70
unhashable
69
71
validator
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