summaryrefslogtreecommitdiff
path: root/tests/urlpatterns
diff options
context:
space:
mode:
authorAngus Holder <aholder97@gmail.com>2020-11-14 17:25:57 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-06-09 09:06:42 +0200
commit3e73c65ffcf263d5ccd107589452a4615281a0e8 (patch)
tree8dc22276119e1ef908452d4b1a6a37ad3932e54b /tests/urlpatterns
parent8f89454bbc873a117cc8614f2d1f1fbfd4e79ee4 (diff)
Fixed #32195 -- Added system check for invalid view in path() and improved error messages.
Diffstat (limited to 'tests/urlpatterns')
-rw-r--r--tests/urlpatterns/tests.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/urlpatterns/tests.py b/tests/urlpatterns/tests.py
index aa593294af..dca9f63086 100644
--- a/tests/urlpatterns/tests.py
+++ b/tests/urlpatterns/tests.py
@@ -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 "