diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index 64b84dbff..6ecdf9ce3 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -15,6 +15,15 @@ urlpatterns = [ path("health/", health.health), path("edit_profile/", profile.edit_profile, name="edit-profile"), path("openid/", include("djangooidc.urls")), - # these views respect the DEBUG setting - path("__debug__/", include("debug_toolbar.urls")), ] + +# we normally would guard these with `if settings.DEBUG` but tests run with +# DEBUG = False even when these apps have been loaded because settings.DEBUG +# was actually True. Instead, let's add these URLs any time we are able to +# import the debug toolbar package. +try: + import debug_toolbar + + urlpatterns += [path("__debug__/", include(debug_toolbar.urls))] +except ImportError: + pass diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index b13c84aad..e5becbdf0 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -1,8 +1,6 @@ from django.test import Client, TestCase from django.contrib.auth import get_user_model -from registrar.models import UserProfile - class HealthTest(TestCase): def setUp(self):