Skip to content

Instantly share code, notes, and snippets.

@aipi
Last active September 15, 2022 09:57
Show Gist options
  • Save aipi/0f7806dfd1a96dcdada6adbbb28bb891 to your computer and use it in GitHub Desktop.
Save aipi/0f7806dfd1a96dcdada6adbbb28bb891 to your computer and use it in GitHub Desktop.
Django - Test that URL resolves to the correct view function
from django.test import TestCase
from django.core.urlresolvers import resolve
from solos.views import index
class SolosURLsTestCase(TestCase):
def test_root_url_uses_index_view(self):
"""Test that
the root of the site resolves to the
correct view function
"""
root = resolve('/')
self.assertEqual(root.func, index)
@PyBagheri
Copy link

This wouldn't work for class-based views, because the methods for each class instance aren't the same methods for another one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment