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
12import sys
23import warnings
34from functools import cache
4344 "SQL_WARNING_THRESHOLD" : 500 , # milliseconds
4445 "OBSERVE_REQUEST_CALLBACK" : "debug_toolbar.toolbar.observe_request" ,
4546 "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 ,
4748 "UPDATE_ON_FETCH" : False ,
4849}
4950
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ Change log
44Pending
55-------
66
7+ * Added support for checking if pytest as the test runner when determining
8+ if tests are running.
9+
7105.2.0 (2025-04-29)
811------------------
912
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ Toolbar options
7777
7878* ``IS_RUNNING_TESTS ``
7979
80- Default: ``"test" in sys.argv ``
80+ Default: ``"test" in sys.argv or "PYTEST_VERSION" in os.environ ``
8181
8282 This setting whether the application is running tests. If this resolves to
8383 ``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:
165165
166166.. code-block :: python
167167
168- TESTING = " test" in sys.argv
168+ TESTING = " test" in sys.argv or " PYTEST_VERSION " in os.environ
169169
170170 if not TESTING :
171171 INSTALLED_APPS = [
You can’t perform that action at this time.
0 commit comments