Modified some regression tests to make them independent of the default root urlconf.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15999 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2011-04-02 13:27:17 +00:00
parent bcdbafc88a
commit 3b94af8a84
11 changed files with 38 additions and 41 deletions

View File

@ -16,6 +16,8 @@ EXPIRED_ETAG = '7fae4cd4b0f81e7d2914700043aa8ed6'
class ConditionalGet(TestCase):
urls = 'regressiontests.conditional_processing.urls'
def assertFullResponse(self, response, check_last_modified=True, check_etag=True):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, FULL_RESPONSE)

View File

@ -2,9 +2,9 @@ from django.conf.urls.defaults import *
import views
urlpatterns = patterns('',
('^$', views.index),
('^last_modified/$', views.last_modified_view1),
('^last_modified2/$', views.last_modified_view2),
('^etag/$', views.etag_view1),
('^etag2/$', views.etag_view2),
('^condition/$', views.index),
('^condition/last_modified/$', views.last_modified_view1),
('^condition/last_modified2/$', views.last_modified_view2),
('^condition/etag/$', views.etag_view1),
('^condition/etag2/$', views.etag_view2),
)

View File

@ -94,6 +94,8 @@ class BadExceptionMiddleware(TestMiddleware):
class BaseMiddlewareExceptionTest(TestCase):
urls = 'regressiontests.middleware_exceptions.urls'
def setUp(self):
self.exceptions = []
got_request_exception.connect(self._on_request_exception)
@ -768,6 +770,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
_missing = object()
class RootUrlconfTests(TestCase):
urls = 'regressiontests.middleware_exceptions.urls'
def test_missing_root_urlconf(self):
try:
original_ROOT_URLCONF = settings.ROOT_URLCONF

View File

@ -4,12 +4,12 @@ from django.conf.urls.defaults import *
import views
urlpatterns = patterns('',
(r'^view/$', views.normal_view),
(r'^not_found/$', views.not_found),
(r'^error/$', views.server_error),
(r'^null_view/$', views.null_view),
(r'^permission_denied/$', views.permission_denied),
(r'^middleware_exceptions/view/$', views.normal_view),
(r'^middleware_exceptions/not_found/$', views.not_found),
(r'^middleware_exceptions/error/$', views.server_error),
(r'^middleware_exceptions/null_view/$', views.null_view),
(r'^middleware_exceptions/permission_denied/$', views.permission_denied),
(r'^template_response/$', views.template_response),
(r'^template_response_error/$', views.template_response_error),
(r'^middleware_exceptions/template_response/$', views.template_response),
(r'^middleware_exceptions/template_response_error/$', views.template_response_error),
)

View File

@ -6,6 +6,7 @@ from django.contrib.auth.models import User
class SpecialHeadersTest(TestCase):
fixtures = ['data.xml']
urls = 'regressiontests.special_headers.urls'
def setUp(self):
self.save_warnings_state()

View File

@ -5,7 +5,7 @@ from models import Article
import views
urlpatterns = patterns('',
(r'^article/(?P<object_id>\d+)/$', object_detail, {'queryset': Article.objects.all()}),
(r'^xview/func/$', views.xview_dec(views.xview)),
(r'^xview/class/$', views.xview_dec(views.XViewClass.as_view())),
(r'^special_headers/article/(?P<object_id>\d+)/$', object_detail, {'queryset': Article.objects.all()}),
(r'^special_headers/xview/func/$', views.xview_dec(views.xview)),
(r'^special_headers/xview/class/$', views.xview_dec(views.XViewClass.as_view())),
)

View File

@ -35,6 +35,7 @@ class SyndicationFeedTest(FeedTestCase):
"""
Tests for the high-level syndication feed framework.
"""
urls = 'regressiontests.syndication.urls'
def test_rss2_feed(self):
"""

View File

@ -3,14 +3,14 @@ from django.conf.urls.defaults import *
import feeds
urlpatterns = patterns('django.contrib.syndication.views',
(r'^complex/(?P<foo>.*)/$', feeds.ComplexFeed()),
(r'^rss2/$', feeds.TestRss2Feed()),
(r'^rss091/$', feeds.TestRss091Feed()),
(r'^atom/$', feeds.TestAtomFeed()),
(r'^custom/$', feeds.TestCustomFeed()),
(r'^naive-dates/$', feeds.NaiveDatesFeed()),
(r'^aware-dates/$', feeds.TZAwareDatesFeed()),
(r'^feedurl/$', feeds.TestFeedUrlFeed()),
(r'^articles/$', feeds.ArticlesFeed()),
(r'^template/$', feeds.TemplateFeed()),
(r'^syndication/complex/(?P<foo>.*)/$', feeds.ComplexFeed()),
(r'^syndication/rss2/$', feeds.TestRss2Feed()),
(r'^syndication/rss091/$', feeds.TestRss091Feed()),
(r'^syndication/atom/$', feeds.TestAtomFeed()),
(r'^syndication/custom/$', feeds.TestCustomFeed()),
(r'^syndication/naive-dates/$', feeds.NaiveDatesFeed()),
(r'^syndication/aware-dates/$', feeds.TZAwareDatesFeed()),
(r'^syndication/feedurl/$', feeds.TestFeedUrlFeed()),
(r'^syndication/articles/$', feeds.ArticlesFeed()),
(r'^syndication/template/$', feeds.TemplateFeed()),
)

View File

@ -19,6 +19,8 @@ class SkippingTestCase(TestCase):
class AssertNumQueriesTests(TestCase):
urls = 'regressiontests.test_utils.urls'
def test_assert_num_queries(self):
def test_func():
raise ValueError
@ -48,6 +50,8 @@ class AssertNumQueriesTests(TestCase):
self.assertNumQueries(2, test_func)
class AssertNumQueriesContextManagerTests(TestCase):
urls = 'regressiontests.test_utils.urls'
def test_simple(self):
with self.assertNumQueries(0):
pass

View File

@ -4,5 +4,5 @@ import views
urlpatterns = patterns('',
(r'^get_person/(\d+)/$', views.get_person),
(r'^test_utils/get_person/(\d+)/$', views.get_person),
)

View File

@ -30,19 +30,4 @@ urlpatterns = patterns('',
(r'widget_admin/', include('regressiontests.admin_widgets.urls')),
(r'^utils/', include('regressiontests.utils.urls')),
# test urlconf for syndication tests
(r'^syndication/', include('regressiontests.syndication.urls')),
# conditional get views
(r'condition/', include('regressiontests.conditional_processing.urls')),
# middleware exceptions tests
(r'middleware_exceptions/', include('regressiontests.middleware_exceptions.urls')),
# special headers views
(r'special_headers/', include('regressiontests.special_headers.urls')),
# test util views
(r'test_utils/', include('regressiontests.test_utils.urls')),
)