8000 Add a section to the installation docs about running tests · matthiask/django-debug-toolbar@546e4b0 · GitHub
  • [go: up one dir, main page]

    Skip to content

    Commit 546e4b0

    Browse files
    committed
    Add a section to the installation docs about running tests
    Fixes django-commons#1920. I thought about including the relevant documentation in the earlier steps, but I'd have to explain DEBUG, INTERNAL_IPS and TESTING all at once instead of introducing everything step by step. So even though it may be annoying to go back and modify code the user just added it still reads better to me, especially since it only applies to users running tests in their project. (I would hope a lot of them do, but still.)
    1 parent 97b49d1 commit 546e4b0

    File tree

    1 file changed

    +24
    -0
    lines changed

    1 file changed

    +24
    -0
    lines changed

    docs/installation.rst

    Lines changed: 24 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -156,6 +156,30 @@ option.
    156156
    able to get the toolbar to work with your docker installation, review
    157157
    the code in ``debug_toolbar.middleware.show_toolbar``.
    158158

    159+
    7. Disable the toolbar when running tests (optional)
    160+
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    161+
    162+
    If you're running tests in your project you shouldn't activate the toolbar. You can do this by adding another setting:
    163+
    164+
    .. code-block:: python
    165+
    166+
    TESTING = "argv" in sys.argv
    167+
    168+
    if not TESTING:
    169+
    INSTALLED_APPS = [*INSTALLED_APPS, "debug_toolbar"]
    170+
    MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware", *MIDDLEWARE]
    171+
    172+
    You should also modify your URLconf file:
    173+
    174+
    .. code-block:: python
    175+
    176+
    if not settings.TESTING:
    177+
    urlpatterns = [
    178+
    *urlpatterns,
    179+
    path("__debug__/", include("debug_toolbar.urls")),
    180+
    ]
    181+
    182+
    159183
    Troubleshooting
    160184
    ---------------
    161185

    0 commit comments

    Comments
     (0)
    0