diff options
Diffstat (limited to 'tests/check_framework/test_urls.py')
| -rw-r--r-- | tests/check_framework/test_urls.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/check_framework/test_urls.py b/tests/check_framework/test_urls.py index 67de26c690..217b5e7bad 100644 --- a/tests/check_framework/test_urls.py +++ b/tests/check_framework/test_urls.py @@ -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) |
