1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #30318 -- Added check for importability of arguments of custom error handler views.

Thanks to Jon on Stack Overflow for reporting the issue.
This commit is contained in:
Alasdair Nicol
2019-04-04 00:17:25 +01:00
committed by Mariusz Felisiak
parent fc9566d42d
commit a5accc0368
5 changed files with 44 additions and 2 deletions

View File

@@ -181,6 +181,29 @@ class CheckCustomErrorHandlersTests(SimpleTestCase):
id='urls.E007',
))
@override_settings(ROOT_URLCONF='check_framework.urls.bad_error_handlers_invalid_path')
def test_bad_handlers_invalid_path(self):
result = check_url_config(None)
paths = [
'django.views.bad_handler',
'django.invalid_module.bad_handler',
'invalid_module.bad_handler',
'django',
]
hints = [
"Could not import '{}'. View does not exist in module django.views.",
"Could not import '{}'. Parent module django.invalid_module does not exist.",
"No module named 'invalid_module'",
"Could not import '{}'. The path must be fully qualified.",
]
for code, path, hint, error in zip([400, 403, 404, 500], paths, hints, result):
with self.subTest('handler{}'.format(code)):
self.assertEqual(error, Error(
"The custom handler{} view '{}' could not be imported.".format(code, path),
hint=hint.format(path),
id='urls.E008',
))
@override_settings(ROOT_URLCONF='check_framework.urls.good_error_handlers')
def test_good_handlers(self):
result = check_url_config(None)