diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-14 17:48:51 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-28 17:02:29 +0100 |
| commit | cf1f36bb6eb34fafe6c224003ad585a647f6117b (patch) | |
| tree | 7e3714ca48a6456ba5d3ebed2fc873f9ff0e6dc6 /tests | |
| parent | e53495ba3352c2c0fdb6178f2b333c30cb6b5d46 (diff) | |
Deprecated current_app in TemplateResponse and render(_to_response).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/shortcuts/tests.py | 4 | ||||
| -rw-r--r-- | tests/template_tests/test_custom.py | 8 | ||||
| -rw-r--r-- | tests/template_tests/test_response.py | 10 |
3 files changed, 15 insertions, 7 deletions
diff --git a/tests/shortcuts/tests.py b/tests/shortcuts/tests.py index 429738b22f..984373bfe7 100644 --- a/tests/shortcuts/tests.py +++ b/tests/shortcuts/tests.py @@ -54,7 +54,7 @@ class ShortcutTests(TestCase): self.assertEqual(response.status_code, 200) self.assertEqual(response.content, b'FOO.BAR../path/to/static/media/\n') self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8') - self.assertEqual(response.context.current_app, None) + self.assertFalse(hasattr(response.context.request, 'current_app')) def test_render_with_base_context(self): with warnings.catch_warnings(): @@ -79,7 +79,7 @@ class ShortcutTests(TestCase): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) response = self.client.get('/render/current_app/') - self.assertEqual(response.context.current_app, "foobar_app") + self.assertEqual(response.context.request.current_app, "foobar_app") def test_render_with_dirs(self): with warnings.catch_warnings(): diff --git a/tests/template_tests/test_custom.py b/tests/template_tests/test_custom.py index c2dff03b10..f0768ba2a5 100644 --- a/tests/template_tests/test_custom.py +++ b/tests/template_tests/test_custom.py @@ -1,9 +1,11 @@ from __future__ import unicode_literals from unittest import TestCase +import warnings from django import template from django.utils import six +from django.utils.deprecation import RemovedInDjango20Warning from .templatetags import custom @@ -253,8 +255,10 @@ class CustomTagTests(TestCase): t = template.Template('{% load custom %}{% inclusion_tag_current_app %}') self.assertEqual(t.render(c).strip(), 'None') - c.current_app = 'advanced' - self.assertEqual(t.render(c).strip(), 'advanced') + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) + c = template.Context({}, current_app='advanced') + self.assertEqual(t.render(c).strip(), 'advanced') def test_15070_use_l10n(self): """ diff --git a/tests/template_tests/test_response.py b/tests/template_tests/test_response.py index f827b2eeab..ab01da5804 100644 --- a/tests/template_tests/test_response.py +++ b/tests/template_tests/test_response.py @@ -1,9 +1,10 @@ from __future__ import unicode_literals +from datetime import datetime import os import pickle import time -from datetime import datetime +import warnings from django.test import RequestFactory, SimpleTestCase from django.conf import settings @@ -12,6 +13,7 @@ from django.template.response import (TemplateResponse, SimpleTemplateResponse, ContentNotRenderedError) from django.test import override_settings from django.utils._os import upath +from django.utils.deprecation import RemovedInDjango20Warning def test_processor(request): @@ -252,11 +254,13 @@ class TemplateResponseTest(SimpleTestCase): self.assertEqual(response.status_code, 504) def test_custom_app(self): - response = self._response('{{ foo }}', current_app="foobar") + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) + response = self._response('{{ foo }}', current_app="foobar") rc = response.resolve_context(response.context_data) - self.assertEqual(rc.current_app, 'foobar') + self.assertEqual(rc.request.current_app, 'foobar') def test_pickling(self): # Create a template response. The context is |
