Guest User

Untitled

a guest
Sep 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. urlpatterns = [
  2. path('u/<int:unit_id>/', views.unit_view, name='unit_view'),
  3. path('u/<int:unit_id>/edit/', views.unit_edit, name='unit_edit'),
  4. ]
  5.  
  6. from django.urls import reverse, resolve
  7. from django.test import TestCase
  8.  
  9.  
  10. class TestUrls(TestCase):
  11.  
  12. def test_unit_view_url(self):
  13. path = reverse('unit_view', kwargs={'unit_id': 1})
  14. self.assertEqual('unit_view', resolve(path).views.unit_view)
  15.  
  16. def test_unit_edit_url(self):
  17. path = reverse('unit_edit', kwargs={'unit_id': 1})
  18. assert resolve(path).views.unit_edit == 'unit_edit'
  19.  
  20. ERROR: test_unit_view_url (decentmark.tests.test_urls.TestUrls)
  21. ----------------------------------------------------------------------
  22. Traceback (most recent call last):
  23. File "C:UsersPrabhanjanDocumentsGitHubdecentmarkdecentmarkteststest_urls.py", line 8, in test_unit_view_url
  24. path = reverse('unit_view', kwargs={'unit_id': 1})
  25. File "C:UsersPrabhanjanAppDataLocalProgramsPythonPython36libsite-packagesdjangourlsbase.py", line 90, in r
  26. everse
  27. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  28. File "C:UsersPrabhanjanAppDataLocalProgramsPythonPython36libsite-packagesdjangourlsresolvers.py", line 622
  29. , in _reverse_with_prefix
  30. raise NoReverseMatch(msg)
  31. django.urls.exceptions.NoReverseMatch: Reverse for 'unit_view' not found. 'unit_view' is not a valid view function or pa
  32. ttern name.
Add Comment
Please, Sign In to add comment