From 64ba7d8252656f89867bc3017812f604786dba2d Mon Sep 17 00:00:00 2001 From: Marten Kenbeek Date: Tue, 22 Dec 2015 22:10:52 +0100 Subject: [PATCH] Moved URLObject in tests to separate utils module. --- .../included_namespace_urls.py | 2 +- tests/urlpatterns_reverse/namespace_urls.py | 2 +- tests/urlpatterns_reverse/tests.py | 21 +--------------- tests/urlpatterns_reverse/utils.py | 25 +++++++++++++++++++ 4 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 tests/urlpatterns_reverse/utils.py diff --git a/tests/urlpatterns_reverse/included_namespace_urls.py b/tests/urlpatterns_reverse/included_namespace_urls.py index 8b2e9dbda18..4f68e4c6025 100644 --- a/tests/urlpatterns_reverse/included_namespace_urls.py +++ b/tests/urlpatterns_reverse/included_namespace_urls.py @@ -1,6 +1,6 @@ from django.conf.urls import include, url -from .namespace_urls import URLObject +from .utils import URLObject from .views import empty_view, view_class_instance testobj3 = URLObject('testapp', 'test-ns3') diff --git a/tests/urlpatterns_reverse/namespace_urls.py b/tests/urlpatterns_reverse/namespace_urls.py index 7fddce8f8eb..fa6359dec2b 100644 --- a/tests/urlpatterns_reverse/namespace_urls.py +++ b/tests/urlpatterns_reverse/namespace_urls.py @@ -1,7 +1,7 @@ from django.conf.urls import include, url from . import views -from .tests import URLObject +from .utils import URLObject testobj1 = URLObject('testapp', 'test-ns1') testobj2 = URLObject('testapp', 'test-ns2') diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py index 93e86df71e2..e32ec03e99b 100644 --- a/tests/urlpatterns_reverse/tests.py +++ b/tests/urlpatterns_reverse/tests.py @@ -29,6 +29,7 @@ from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning from . import middleware, urlconf_outer, views +from .utils import URLObject from .views import empty_view resolve_test_data = ( @@ -242,26 +243,6 @@ test_data = ( ) -class URLObject(object): - urlpatterns = [ - url(r'^inner/$', views.empty_view, name='urlobject-view'), - url(r'^inner/(?P[0-9]+)/(?P[0-9]+)/$', views.empty_view, name='urlobject-view'), - url(r'^inner/\+\\\$\*/$', views.empty_view, name='urlobject-special-view'), - ] - - def __init__(self, app_name, namespace=None): - self.app_name = app_name - self.namespace = namespace - - @property - def urls(self): - return self.urlpatterns, self.app_name, self.namespace - - @property - def app_urls(self): - return self.urlpatterns, self.app_name - - @override_settings(ROOT_URLCONF='urlpatterns_reverse.no_urls') class NoURLPatternsTests(SimpleTestCase): diff --git a/tests/urlpatterns_reverse/utils.py b/tests/urlpatterns_reverse/utils.py new file mode 100644 index 00000000000..6c3fe8a31dc --- /dev/null +++ b/tests/urlpatterns_reverse/utils.py @@ -0,0 +1,25 @@ +from __future__ import unicode_literals + +from django.conf.urls import url + +from . import views + + +class URLObject(object): + urlpatterns = [ + url(r'^inner/$', views.empty_view, name='urlobject-view'), + url(r'^inner/(?P[0-9]+)/(?P[0-9]+)/$', views.empty_view, name='urlobject-view'), + url(r'^inner/\+\\\$\*/$', views.empty_view, name='urlobject-special-view'), + ] + + def __init__(self, app_name, namespace=None): + self.app_name = app_name + self.namespace = namespace + + @property + def urls(self): + return self.urlpatterns, self.app_name, self.namespace + + @property + def app_urls(self): + return self.urlpatterns, self.app_name