Skip to content

Add a section to the installation docs about running tests #1921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Pending

* Removed some CSS which wasn't carefully limited to the toolbar's elements.
* Stopped assuming that ``INTERNAL_IPS`` is a list.
* Added a section to the installation docs about running tests in projects
where the toolbar is being used.


4.4.1 (2024-05-26)
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Toolbar options
The toolbar searches for this string in the HTML and inserts itself just
before.

.. _IS_RUNNING_TESTS:

* ``IS_RUNNING_TESTS``

Default: ``"test" in sys.argv``
Expand Down
33 changes: 33 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,39 @@ option.
able to get the toolbar to work with your docker installation, review
the code in ``debug_toolbar.middleware.show_toolbar``.

7. Disable the toolbar when running tests (optional)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you're running tests in your project you shouldn't activate the toolbar. You
can do this by adding another setting:

.. code-block:: python

TESTING = "test" in sys.argv

if not TESTING:
INSTALLED_APPS = [
*INSTALLED_APPS,
"debug_toolbar",
]
MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware",
*MIDDLEWARE,
]

You should also modify your URLconf file:

.. code-block:: python

if not settings.TESTING:
urlpatterns = [
*urlpatterns,
path("__debug__/", include("debug_toolbar.urls")),
]

Alternatively, you can check out the :ref:`IS_RUNNING_TESTS <IS_RUNNING_TESTS>`
option.

Troubleshooting
---------------

Expand Down