diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-12 22:31:44 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-12 22:31:44 +0100 |
| commit | 5f7230e12f0d237cdc19d8930006b0fc7d9dbaa6 (patch) | |
| tree | 3780335d2abb7d5e760c8ef7ac4819ba6e154574 /tests | |
| parent | 511a53b3142551a1bc3093ed1b6655f57634f510 (diff) | |
Fixed #24124 (again) -- Updated tests with new default context_processors.
Thanks Collin for the review.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_views/tests.py | 9 | ||||
| -rwxr-xr-x | tests/runtests.py | 7 | ||||
| -rw-r--r-- | tests/shortcuts/templates/shortcuts/render_test.html | 2 | ||||
| -rw-r--r-- | tests/shortcuts/tests.py | 11 | ||||
| -rw-r--r-- | tests/timezones/tests.py | 12 |
5 files changed, 18 insertions, 23 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 04dfb096a5..f991982fe5 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -800,10 +800,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.tz', - 'django.template.context_processors.media', - 'django.template.context_processors.static', + 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], @@ -4499,9 +4496,7 @@ class AdminDocsTest(TestCase): 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', - 'django.template.context_processors.tz', - 'django.template.context_processors.media', - 'django.template.context_processors.static', + 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], diff --git a/tests/runtests.py b/tests/runtests.py index f742c57bbb..f3ec6407c9 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -123,12 +123,9 @@ def setup(verbosity, test_labels): 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ - 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.static', - 'django.template.context_processors.tz', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, diff --git a/tests/shortcuts/templates/shortcuts/render_test.html b/tests/shortcuts/templates/shortcuts/render_test.html index 1b2f47a0e3..c2bbd9aa79 100644 --- a/tests/shortcuts/templates/shortcuts/render_test.html +++ b/tests/shortcuts/templates/shortcuts/render_test.html @@ -1 +1 @@ -{{ foo }}.{{ bar }}.{{ baz }}.{{ STATIC_URL }} +{{ foo }}.{{ bar }}.{{ baz }}.{{ request.path }} diff --git a/tests/shortcuts/tests.py b/tests/shortcuts/tests.py index f5351dfa03..e22cf4d386 100644 --- a/tests/shortcuts/tests.py +++ b/tests/shortcuts/tests.py @@ -3,7 +3,6 @@ from django.test import TestCase, ignore_warnings, override_settings @override_settings( - STATIC_URL='/path/to/static/media/', ROOT_URLCONF='shortcuts.urls', ) class ShortcutTests(TestCase): @@ -23,7 +22,7 @@ class ShortcutTests(TestCase): def test_render_to_response_with_request_context(self): response = self.client.get('/render_to_response/request_context/') self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, b'FOO.BAR../path/to/static/media/\n') + self.assertEqual(response.content, b'FOO.BAR../render_to_response/request_context/\n') self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8') def test_render_to_response_with_content_type(self): @@ -52,14 +51,14 @@ class ShortcutTests(TestCase): def test_render(self): response = self.client.get('/render/') self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, b'FOO.BAR../path/to/static/media/\n') + self.assertEqual(response.content, b'FOO.BAR../render/\n') self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8') self.assertFalse(hasattr(response.context.request, 'current_app')) def test_render_with_multiple_templates(self): response = self.client.get('/render/multiple_templates/') self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, b'FOO.BAR../path/to/static/media/\n') + self.assertEqual(response.content, b'FOO.BAR../render/multiple_templates/\n') @ignore_warnings(category=RemovedInDjango20Warning) def test_render_with_base_context(self): @@ -71,13 +70,13 @@ class ShortcutTests(TestCase): def test_render_with_content_type(self): response = self.client.get('/render/content_type/') self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, b'FOO.BAR../path/to/static/media/\n') + self.assertEqual(response.content, b'FOO.BAR../render/content_type/\n') self.assertEqual(response['Content-Type'], 'application/x-rendertest') def test_render_with_status(self): response = self.client.get('/render/status/') self.assertEqual(response.status_code, 403) - self.assertEqual(response.content, b'FOO.BAR../path/to/static/media/\n') + self.assertEqual(response.content, b'FOO.BAR../render/status/\n') @ignore_warnings(category=RemovedInDjango20Warning) def test_render_with_current_app(self): diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 586e838e37..677d51ac2e 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -16,8 +16,10 @@ from django.core import serializers from django.core.urlresolvers import reverse from django.db.models import Min, Max from django.http import HttpRequest -from django.template import Context, RequestContext, Template, TemplateSyntaxError -from django.test import TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature +from django.template import ( + context_processors, Context, RequestContext, Template, TemplateSyntaxError) +from django.test import ( + TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature) from django.test.utils import requires_tz_support from django.utils import six from django.utils import timezone @@ -935,8 +937,10 @@ class TemplateTests(TestCase): Test the django.template.context_processors.tz template context processor. """ tpl = Template("{{ TIME_ZONE }}") - self.assertEqual(tpl.render(Context()), "") - self.assertEqual(tpl.render(RequestContext(HttpRequest())), "Africa/Nairobi" if pytz else "EAT") + context = Context() + self.assertEqual(tpl.render(context), "") + request_context = RequestContext(HttpRequest(), processors=[context_processors.tz]) + self.assertEqual(tpl.render(request_context), "Africa/Nairobi" if pytz else "EAT") @requires_tz_support def test_date_and_time_template_filters(self): |
