Skip to content

Commit db3c42e

Browse files
committed
fix(tests): Disable the debug toolbar when running tests
1 parent f462418 commit db3c42e

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

bc/settings/django.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
MIDDLEWARE.append(
6565
"django_browser_reload.middleware.BrowserReloadMiddleware"
6666
)
67-
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
67+
if not TESTING:
68+
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
6869

6970
ROOT_URLCONF = "bc.urls"
7071
AUTH_USER_MODEL = "users.User"

bc/settings/project/security.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ..django import DEVELOPMENT, INSTALLED_APPS, TESTING
66
from ..third_party.aws import AWS_S3_CUSTOM_DOMAIN
77
from ..third_party.sentry import SENTRY_REPORT_URI
8+
from ..project.testing import TESTING
89

910
env = environ.FileAwareEnv()
1011

@@ -86,7 +87,11 @@
8687
CSRF_COOKIE_SECURE = False
8788
SESSION_COOKIE_DOMAIN = None
8889
# For debug_toolbar
89-
INSTALLED_APPS.append("debug_toolbar")
90+
if not TESTING:
91+
INSTALLED_APPS = [
92+
*INSTALLED_APPS,
93+
"debug_toolbar",
94+
]
9095

9196
# Get the list of IPv4 addresses for the interface on the same host. If you want to know more
9297
# about this, you can check the following links:

bc/urls.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
urlpatterns.append(
2424
path("__reload__/", include("django_browser_reload.urls")),
2525
)
26-
urlpatterns.append(
27-
path("__debug__/", include("debug_toolbar.urls")),
28-
)
26+
if not settings.TESTING:
27+
urlpatterns.append(
28+
path("__debug__/", include("debug_toolbar.urls")),
29+
)
2930
urlpatterns += static( # type: ignore
3031
settings.STATIC_URL, document_root=settings.STATIC_ROOT
3132
)

0 commit comments

Comments
 (0)