From 6df91d9539ae6469ad291cbfe257c84aeaa4d85d Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Mon, 24 Oct 2011 21:30:55 +0000 Subject: [PATCH] Fixed #17086 -- Removed pollution of global template-builtins from markup and humanize tests. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17031 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/humanize/tests.py | 6 ++---- django/contrib/markup/tests.py | 16 +++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/django/contrib/humanize/tests.py b/django/contrib/humanize/tests.py index 17fa2bf3bb..d46cdb05e4 100644 --- a/django/contrib/humanize/tests.py +++ b/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 @@ class HumanizeTests(TestCase): # 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)) diff --git a/django/contrib/markup/tests.py b/django/contrib/markup/tests.py index e97a7def3b..03a653c77a 100644 --- a/django/contrib/markup/tests.py +++ b/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 @@ Paragraph 2 with a link_ @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', ''), """

Paragraph 1

@@ -49,26 +47,26 @@ Paragraph 2 with a link_ @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("""

Paragraph 1\s*

\s*

\s*An 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 @@ Paragraph 2 with a link_ @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)