Fixed #32195 -- Added system check for invalid view in path() and improved error messages.

This commit is contained in:
Angus Holder 2020-11-14 17:25:57 +00:00 committed by Mariusz Felisiak
parent 8f89454bbc
commit 3e73c65ffc
6 changed files with 65 additions and 0 deletions

View file

@ -5,6 +5,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase
from django.test.utils import override_settings
from django.urls import NoReverseMatch, Resolver404, path, resolve, reverse
from django.views import View
from .converters import DynamicConverter
from .views import empty_view
@ -146,6 +147,14 @@ class SimplifiedURLTests(SimpleTestCase):
with self.assertRaisesMessage(TypeError, msg):
path('articles/', 'invalid_view')
def test_invalid_view_instance(self):
class EmptyCBV(View):
pass
msg = 'view must be a callable, pass EmptyCBV.as_view(), not EmptyCBV().'
with self.assertRaisesMessage(TypeError, msg):
path('foo', EmptyCBV())
def test_whitespace_in_route(self):
msg = (
"URL route 'space/<int:num>/extra/<str:%stest>' cannot contain "