Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #17086 -- Removed pollution of global template-builtins from ma…

…rkup and humanize tests.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17031 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6df91d9539ae6469ad291cbfe257c84aeaa4d85d 1 parent d89be53
@carljm carljm authored
View
6 django/contrib/humanize/tests.py
@@ -1,14 +1,12 @@
from __future__ import with_statement
from datetime import timedelta, date, datetime
-from django.template import Template, Context, add_to_builtins, defaultfilters
+from django.template import Template, Context, defaultfilters
from django.test import TestCase
from django.utils import translation, tzinfo
from django.utils.translation import ugettext as _
from django.utils.html import escape
-add_to_builtins('django.contrib.humanize.templatetags.humanize')
-
class HumanizeTests(TestCase):
@@ -16,7 +14,7 @@ def humanize_tester(self, test_list, result_list, method):
# Using max below ensures we go through both lists
# However, if the lists are not equal length, this raises an exception
for test_content, result in zip(test_list, result_list):
- t = Template('{{ test_content|%s }}' % method)
+ t = Template('{%% load humanize %%}{{ test_content|%s }}' % method)
rendered = t.render(Context(locals())).strip()
self.assertEqual(rendered, escape(result),
msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
View
16 django/contrib/markup/tests.py
@@ -1,12 +1,10 @@
# Quick tests for the markup templatetags (django.contrib.markup)
import re
-from django.template import Template, Context, add_to_builtins
+from django.template import Template, Context
from django.utils import unittest
from django.utils.html import escape
-add_to_builtins('django.contrib.markup.templatetags.markup')
-
try:
import textile
except ImportError:
@@ -41,7 +39,7 @@ class Templates(unittest.TestCase):
@unittest.skipUnless(textile, 'texttile not installed')
def test_textile(self):
- t = Template("{{ textile_content|textile }}")
+ t = Template("{% load markup %}{{ textile_content|textile }}")
rendered = t.render(Context({'textile_content':self.textile_content})).strip()
self.assertEqual(rendered.replace('\t', ''), """<p>Paragraph 1</p>
@@ -49,26 +47,26 @@ def test_textile(self):
@unittest.skipIf(textile, 'texttile is installed')
def test_no_textile(self):
- t = Template("{{ textile_content|textile }}")
+ t = Template("{% load markup %}{{ textile_content|textile }}")
rendered = t.render(Context({'textile_content':self.textile_content})).strip()
self.assertEqual(rendered, escape(self.textile_content))
@unittest.skipUnless(markdown, 'markdown not installed')
def test_markdown(self):
- t = Template("{{ markdown_content|markdown }}")
+ t = Template("{% load markup %}{{ markdown_content|markdown }}")
rendered = t.render(Context({'markdown_content':self.markdown_content})).strip()
pattern = re.compile("""<p>Paragraph 1\s*</p>\s*<h2>\s*An h2</h2>""")
self.assertTrue(pattern.match(rendered))
@unittest.skipIf(markdown, 'markdown is installed')
def test_no_markdown(self):
- t = Template("{{ markdown_content|markdown }}")
+ t = Template("{% load markup %}{{ markdown_content|markdown }}")
rendered = t.render(Context({'markdown_content':self.markdown_content})).strip()
self.assertEqual(rendered, self.markdown_content)
@unittest.skipUnless(docutils, 'docutils not installed')
def test_docutils(self):
- t = Template("{{ rest_content|restructuredtext }}")
+ t = Template("{% load markup %}{{ rest_content|restructuredtext }}")
rendered = t.render(Context({'rest_content':self.rest_content})).strip()
# Different versions of docutils return slightly different HTML
try:
@@ -82,7 +80,7 @@ def test_docutils(self):
@unittest.skipIf(docutils, 'docutils is installed')
def test_no_docutils(self):
- t = Template("{{ rest_content|restructuredtext }}")
+ t = Template("{% load markup %}{{ rest_content|restructuredtext }}")
rendered = t.render(Context({'rest_content':self.rest_content})).strip()
self.assertEqual(rendered, self.rest_content)

0 comments on commit 6df91d9

Please sign in to comment.
Something went wrong with that request. Please try again.