From 7ea9dc9d7df5420d73bae60121003112cc5944d7 Mon Sep 17 00:00:00 2001 From: Daniel Harding Date: Fri, 25 Apr 2014 08:38:06 -0500 Subject: Improve the redirect context processor test. * rename the context processor used from 'custom' to 'broken' * remove the custom middleware, because it is not used in the context of the test * rename the test to better identify what it is testing --- tests/context_processors.py | 2 +- tests/middlewares.py | 5 ----- tests/panels/test_redirects.py | 10 +++------- 3 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 tests/middlewares.py (limited to 'tests') diff --git a/tests/context_processors.py b/tests/context_processors.py index 4c08000..6fe220d 100644 --- a/tests/context_processors.py +++ b/tests/context_processors.py @@ -1,2 +1,2 @@ -def custom(request): +def broken(request): request.non_existing_attribute diff --git a/tests/middlewares.py b/tests/middlewares.py deleted file mode 100644 index 44a3ef1..0000000 --- a/tests/middlewares.py +++ /dev/null @@ -1,5 +0,0 @@ - - -class CustomMiddleware(object): - def process_request(request): - request.myattr = 'test attribute' diff --git a/tests/panels/test_redirects.py b/tests/panels/test_redirects.py index 71d53da..1fa773c 100644 --- a/tests/panels/test_redirects.py +++ b/tests/panels/test_redirects.py @@ -33,16 +33,12 @@ class RedirectsPanelTestCase(BaseTestCase): self.assertContains(response, '302 FOUND') self.assertContains(response, 'http://somewhere/else/') - def test_redirect_breaks_procesor(self): - middlewares = settings.MIDDLEWARE_CLASSES + [ - 'tests.middlewares.CustomMiddleware', - ] + def test_redirect_with_broken_context_processor(self): context_processors = settings.TEMPLATE_CONTEXT_PROCESSORS + ( - 'tests.context_processors.custom', + 'tests.context_processors.broken', ) - with self.settings(MIDDLEWARE_CLASSES=middlewares, - TEMPLATE_CONTEXT_PROCESSORS=context_processors): + with self.settings(TEMPLATE_CONTEXT_PROCESSORS=context_processors): redirect = HttpResponse(status=302) redirect['Location'] = 'http://somewhere/else/' response = self.panel.process_response(self.request, redirect) -- cgit v1.2.3