From 31c9a9b13d036dd999f7b622cbc5ec6bd4ea36c1 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 5 Jun 2024 11:02:21 -0400 Subject: [PATCH] Disable django-debug-toolbar when running tests --- cmsmanage/settings.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmsmanage/settings.py b/cmsmanage/settings.py index d83c33f..5fb5e0e 100644 --- a/cmsmanage/settings.py +++ b/cmsmanage/settings.py @@ -1,4 +1,5 @@ import os +import sys from pathlib import Path from django.core import validators @@ -303,8 +304,15 @@ class Dev(NonCIBase): DEBUG = values.BooleanValue(True) INTERNAL_IPS = ["127.0.0.1"] - INSTALLED_APPS = NonCIBase.INSTALLED_APPS + ["debug_toolbar", "django_extensions"] - MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + Base.MIDDLEWARE + INSTALLED_APPS = NonCIBase.INSTALLED_APPS + ["django_extensions"] + + # bit of a hack to disable debug toolbar when running tests + if DEBUG and "test" not in sys.argv: + INSTALLED_APPS += ["debug_toolbar"] + MIDDLEWARE = NonCIBase.MIDDLEWARE + [ + "debug_toolbar.middleware.DebugToolbarMiddleware", + ] + EMAIL = values.EmailURLValue("smtp://localhost:1025") # for local `mailpit` SENDFILE_BACKEND = "django_sendfile.backends.development"