I have these urls under my urls.py. I didn't add a lot of URL patterns to the code as they're not relevant to the issue.
SWAGGER_URLS = [url(r'^swagger(?P<format>\.json|\.yaml)$',
                    schema_view.without_ui(cache_timeout=0), name='schema-json'),
                url(r'^swagger/$', schema_view.with_ui('swagger',
                                                       cache_timeout=0), name='swagger')]
urlpatterns = USER_URLS + USER_INTEREST_URLS + FOLLOW_USER_URLS + \
              GOAL_URLS + GOAL_CATEGORY_URLS + JOIN_GOAL_URLS + \
              POST_URLS + EXPLORE_URLS + HOME_FEED_URLS + SEARCH_URLS + FOLLOW_JOIN_GOAL_URLS
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns += ADMIN_URLS
    urlpatterns += SWAGGER_URLS
then I have this test SwaggerTest.py
from django.test import TestCase
from django.urls import reverse
from rest_framework import status
class SwaggerTest(TestCase):
    @override_settings(DEBUG=True)
    def test_successful_swagger_pint(self):
        response = self.client.get(reverse('swagger'))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
I'm getting the exception django.urls.exceptions.NoReverseMatch: Reverse for 'swagger' not found. 'swagger' is not a valid view function or pattern name. when I run this test. When I ping the url myself by going to localhost/swagger/ with my browser and it works fine. I'm using django-rest-swagger==2.2.0.
I run the test by running the commands python manage.py test <path to Swagger test>