2017-12-19 22:50:23 +00:00
|
|
|
from django.test import SimpleTestCase
|
2019-05-06 20:53:40 +00:00
|
|
|
from django.test.utils import override_settings
|
|
|
|
from django.urls.resolvers import RegexPattern, RoutePattern, get_resolver
|
2017-12-19 22:50:23 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
|
|
|
|
class RegexPatternTests(SimpleTestCase):
|
|
|
|
def test_str(self):
|
2022-02-03 19:24:19 +00:00
|
|
|
self.assertEqual(str(RegexPattern(_("^translated/$"))), "^translated/$")
|
2017-12-19 22:50:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RoutePatternTests(SimpleTestCase):
|
|
|
|
def test_str(self):
|
2022-02-03 19:24:19 +00:00
|
|
|
self.assertEqual(str(RoutePattern(_("translated/"))), "translated/")
|
2019-05-06 20:53:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ResolverCacheTests(SimpleTestCase):
|
2022-02-03 19:24:19 +00:00
|
|
|
@override_settings(ROOT_URLCONF="urlpatterns.path_urls")
|
2019-05-06 20:53:40 +00:00
|
|
|
def test_resolver_cache_default__root_urlconf(self):
|
|
|
|
# resolver for a default URLconf (passing no argument) and for the
|
|
|
|
# settings.ROOT_URLCONF is the same cached object.
|
2022-02-03 19:24:19 +00:00
|
|
|
self.assertIs(get_resolver(), get_resolver("urlpatterns.path_urls"))
|
|
|
|
self.assertIsNot(get_resolver(), get_resolver("urlpatterns.path_dynamic_urls"))
|