Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- urlpatterns = [
- path('u/<int:unit_id>/', views.unit_view, name='unit_view'),
- path('u/<int:unit_id>/edit/', views.unit_edit, name='unit_edit'),
- ]
- from django.urls import reverse, resolve
- from django.test import TestCase
- class TestUrls(TestCase):
- def test_unit_view_url(self):
- path = reverse('unit_view', kwargs={'unit_id': 1})
- self.assertEqual('unit_view', resolve(path).views.unit_view)
- def test_unit_edit_url(self):
- path = reverse('unit_edit', kwargs={'unit_id': 1})
- assert resolve(path).views.unit_edit == 'unit_edit'
- ERROR: test_unit_view_url (decentmark.tests.test_urls.TestUrls)
- ----------------------------------------------------------------------
- Traceback (most recent call last):
- File "C:UsersPrabhanjanDocumentsGitHubdecentmarkdecentmarkteststest_urls.py", line 8, in test_unit_view_url
- path = reverse('unit_view', kwargs={'unit_id': 1})
- File "C:UsersPrabhanjanAppDataLocalProgramsPythonPython36libsite-packagesdjangourlsbase.py", line 90, in r
- everse
- return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
- File "C:UsersPrabhanjanAppDataLocalProgramsPythonPython36libsite-packagesdjangourlsresolvers.py", line 622
- , in _reverse_with_prefix
- raise NoReverseMatch(msg)
- django.urls.exceptions.NoReverseMatch: Reverse for 'unit_view' not found. 'unit_view' is not a valid view function or pa
- ttern name.
Add Comment
Please, Sign In to add comment