File tree Expand file tree Collapse file tree 4 files changed +7
-3
lines changed Expand file tree Collapse file tree 4 files changed +7
-3
lines changed Original file line number Diff line number Diff line change
1
+ import os
1
2
import sys
2
3
import warnings
3
4
from functools import cache
43
44
"SQL_WARNING_THRESHOLD" : 500 , # milliseconds
44
45
"OBSERVE_REQUEST_CALLBACK" : "debug_toolbar.toolbar.observe_request" ,
45
46
"TOOLBAR_LANGUAGE" : None ,
46
- "IS_RUNNING_TESTS" : "test" in sys .argv ,
47
+ "IS_RUNNING_TESTS" : "test" in sys .argv or "PYTEST_VERSION" in os . environ ,
47
48
"UPDATE_ON_FETCH" : False ,
48
49
}
49
50
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ Change log
4
4
Pending
5
5
-------
6
6
7
+ * Added support for checking if pytest as the test runner when determining
8
+ if tests are running.
9
+
7
10
5.2.0 (2025-04-29)
8
11
------------------
9
12
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ Toolbar options
77
77
78
78
* ``IS_RUNNING_TESTS ``
79
79
80
- Default: ``"test" in sys.argv ``
80
+ Default: ``"test" in sys.argv or "PYTEST_VERSION" in os.environ ``
81
81
82
82
This setting whether the application is running tests. If this resolves to
83
83
``True ``, the toolbar will prevent you from running tests. This should only
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ can do this by adding another setting:
165
165
166
166
.. code-block :: python
167
167
168
- TESTING = " test" in sys.argv
168
+ TESTING = " test" in sys.argv or " PYTEST_VERSION " in os.environ
169
169
170
170
if not TESTING :
171
171
INSTALLED_APPS = [
You can’t perform that action at this time.
0 commit comments