diff options
| author | Tim Graham <timograham@gmail.com> | 2015-09-03 15:52:04 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-09-23 19:31:10 -0400 |
| commit | 5e450c52aafb62b9d83c8ac08892e0b92cbec4aa (patch) | |
| tree | dbc6b0360aba68d492dc0925d527c9c0f237f401 /tests | |
| parent | 75374d3797c2cd2423982a870bb0bc74821e951f (diff) | |
Removed current_app argument to render() and TemplateResponse().
Per deprecation timeline.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/shortcuts/tests.py | 10 | ||||
| -rw-r--r-- | tests/shortcuts/urls.py | 2 | ||||
| -rw-r--r-- | tests/shortcuts/views.py | 16 | ||||
| -rw-r--r-- | tests/template_tests/templates/test_incl_tag_current_app.html | 1 | ||||
| -rw-r--r-- | tests/template_tests/templatetags/inclusion.py | 7 | ||||
| -rw-r--r-- | tests/template_tests/test_custom.py | 18 | ||||
| -rw-r--r-- | tests/template_tests/test_response.py | 13 |
7 files changed, 7 insertions, 60 deletions
diff --git a/tests/shortcuts/tests.py b/tests/shortcuts/tests.py index ef7a0edc7a..5c44ab20f5 100644 --- a/tests/shortcuts/tests.py +++ b/tests/shortcuts/tests.py @@ -103,18 +103,8 @@ class ShortcutTests(SimpleTestCase): self.assertEqual(response.content, b'Jinja2\n') @ignore_warnings(category=RemovedInDjango110Warning) - def test_render_with_current_app(self): - response = self.client.get('/render/current_app/') - self.assertEqual(response.context.request.current_app, "foobar_app") - - @ignore_warnings(category=RemovedInDjango110Warning) def test_render_with_dirs(self): response = self.client.get('/render/dirs/') self.assertEqual(response.status_code, 200) self.assertEqual(response.content, b'spam eggs\n') self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8') - - @ignore_warnings(category=RemovedInDjango110Warning) - def test_render_with_current_app_conflict(self): - with self.assertRaises(ValueError): - self.client.get('/render/current_app_conflict/') diff --git a/tests/shortcuts/urls.py b/tests/shortcuts/urls.py index 449a840f73..e125709296 100644 --- a/tests/shortcuts/urls.py +++ b/tests/shortcuts/urls.py @@ -18,6 +18,4 @@ urlpatterns = [ url(r'^render/dirs/$', views.render_with_dirs), url(r'^render/status/$', views.render_view_with_status), url(r'^render/using/$', views.render_view_with_using), - url(r'^render/current_app/$', views.render_view_with_current_app), - url(r'^render/current_app_conflict/$', views.render_view_with_current_app_conflict), ] diff --git a/tests/shortcuts/views.py b/tests/shortcuts/views.py index f988edf8d9..e4638106ac 100644 --- a/tests/shortcuts/views.py +++ b/tests/shortcuts/views.py @@ -109,19 +109,3 @@ def render_view_with_status(request): def render_view_with_using(request): using = request.GET.get('using') return render(request, 'shortcuts/using.html', using=using) - - -def render_view_with_current_app(request): - return render(request, 'shortcuts/render_test.html', { - 'foo': 'FOO', - 'bar': 'BAR', - }, current_app="foobar_app") - - -def render_view_with_current_app_conflict(request): - # This should fail because we don't passing both a current_app and - # context_instance: - return render(request, 'shortcuts/render_test.html', { - 'foo': 'FOO', - 'bar': 'BAR', - }, current_app="foobar_app", context_instance=RequestContext(request)) diff --git a/tests/template_tests/templates/test_incl_tag_current_app.html b/tests/template_tests/templates/test_incl_tag_current_app.html deleted file mode 100644 index ab2fe63b6f..0000000000 --- a/tests/template_tests/templates/test_incl_tag_current_app.html +++ /dev/null @@ -1 +0,0 @@ -{% load custom %}{% current_app %} diff --git a/tests/template_tests/templatetags/inclusion.py b/tests/template_tests/templatetags/inclusion.py index 185cdb1917..57fad868e7 100644 --- a/tests/template_tests/templatetags/inclusion.py +++ b/tests/template_tests/templatetags/inclusion.py @@ -166,13 +166,6 @@ def inclusion_only_unlimited_args_from_template(*args): inclusion_only_unlimited_args_from_template.anything = "Expected inclusion_only_unlimited_args_from_template __dict__" -@register.inclusion_tag('test_incl_tag_current_app.html', takes_context=True) -def inclusion_tag_current_app(context): - """Expected inclusion_tag_current_app __doc__""" - return {} -inclusion_tag_current_app.anything = "Expected inclusion_tag_current_app __dict__" - - @register.inclusion_tag('test_incl_tag_use_l10n.html', takes_context=True) def inclusion_tag_use_l10n(context): """Expected inclusion_tag_use_l10n __doc__""" diff --git a/tests/template_tests/test_custom.py b/tests/template_tests/test_custom.py index 48252e1788..12331afce8 100644 --- a/tests/template_tests/test_custom.py +++ b/tests/template_tests/test_custom.py @@ -6,10 +6,9 @@ from unittest import skipUnless from django.template import Context, Engine, TemplateSyntaxError from django.template.base import Node from django.template.library import InvalidTemplateLibrary -from django.test import SimpleTestCase, ignore_warnings +from django.test import SimpleTestCase from django.test.utils import extend_sys_path from django.utils import six -from django.utils.deprecation import RemovedInDjango110Warning from .templatetags import custom, inclusion from .utils import ROOT @@ -270,23 +269,8 @@ class InclusionTagTests(TagTestCase): self.verify_tag(inclusion.inclusion_only_unlimited_args, 'inclusion_only_unlimited_args') self.verify_tag(inclusion.inclusion_tag_without_context_parameter, 'inclusion_tag_without_context_parameter') self.verify_tag(inclusion.inclusion_tag_use_l10n, 'inclusion_tag_use_l10n') - self.verify_tag(inclusion.inclusion_tag_current_app, 'inclusion_tag_current_app') self.verify_tag(inclusion.inclusion_unlimited_args_kwargs, 'inclusion_unlimited_args_kwargs') - @ignore_warnings(category=RemovedInDjango110Warning) - def test_15070_current_app(self): - """ - Test that inclusion tag passes down `current_app` of context to the - Context of the included/rendered template as well. - """ - c = Context({}) - t = self.engine.from_string('{% load inclusion %}{% inclusion_tag_current_app %}') - self.assertEqual(t.render(c).strip(), 'None') - - # That part produces the deprecation warning - c = Context({}, current_app='advanced') - self.assertEqual(t.render(c).strip(), 'advanced') - def test_15070_use_l10n(self): """ Test that inclusion tag passes down `use_l10n` of context to the diff --git a/tests/template_tests/test_response.py b/tests/template_tests/test_response.py index 36a0ba704d..8fea389f53 100644 --- a/tests/template_tests/test_response.py +++ b/tests/template_tests/test_response.py @@ -282,11 +282,6 @@ class TemplateResponseTest(SimpleTestCase): response = TemplateResponse(request, 'template_tests/using.html', using='jinja2').render() self.assertEqual(response.content, b'Jinja2\n') - @ignore_warnings(category=RemovedInDjango110Warning) - def test_custom_app(self): - self._response('{{ foo }}', current_app="foobar") - self.assertEqual(self._request.current_app, 'foobar') - def test_pickling(self): # Create a template response. The context is # known to be unpickleable (e.g., a function). @@ -310,8 +305,12 @@ class TemplateResponseTest(SimpleTestCase): # ...and the unpickled response doesn't have the # template-related attributes, so it can't be re-rendered - template_attrs = ('template_name', 'context_data', - '_post_render_callbacks', '_request', '_current_app') + template_attrs = ( + 'template_name', + 'context_data', + '_post_render_callbacks', + '_request', + ) for attr in template_attrs: self.assertFalse(hasattr(unpickled_response, attr)) |
