Last active
September 15, 2022 09:57
-
-
Save aipi/0f7806dfd1a96dcdada6adbbb28bb891 to your computer and use it in GitHub Desktop.
Django - Test that URL resolves to the correct view function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This wouldn't work for class-based views, because the methods for each class instance aren't the same methods for another one.