MCPcopy
hub / github.com/django/django / test_no_urls_exception

Method test_no_urls_exception

tests/urlpatterns_reverse/tests.py:420–433  ·  view source on GitHub ↗

URLResolver should raise an exception when no urlpatterns exist.

(self)

Source from the content-addressed store, hash-verified

418@override_settings(ROOT_URLCONF="urlpatterns_reverse.no_urls")
419class NoURLPatternsTests(SimpleTestCase):
420 def test_no_urls_exception(self):
421 """
422 URLResolver should raise an exception when no urlpatterns exist.
423 """
424 resolver = URLResolver(RegexPattern(r"^$"), settings.ROOT_URLCONF)
425
426 with self.assertRaisesMessage(
427 ImproperlyConfigured,
428 "The included URLconf 'urlpatterns_reverse.no_urls' does not "
429 "appear to have any patterns in it. If you see the 'urlpatterns' "
430 "variable with valid patterns in the file then the issue is "
431 "probably caused by a circular import.",
432 ):
433 getattr(resolver, "url_patterns")
434
435
436@override_settings(ROOT_URLCONF="urlpatterns_reverse.urls")

Callers

nothing calls this directly

Calls 3

URLResolverClass · 0.90
RegexPatternClass · 0.90
assertRaisesMessageMethod · 0.80

Tested by

no test coverage detected