summaryrefslogtreecommitdiff
path: root/tests/othertests
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-12-09 04:29:20 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-12-09 04:29:20 +0000
commit63cf85b64d3cb84e151f1994a6116c17deaefb33 (patch)
tree0567f76ebbc1827070e0882fc5540430df80b933 /tests/othertests
parent4e7006856d76e11b68233e7a846df0ae4d10170c (diff)
Moved custom unit-test templatetag library into the unit test module itself, to fix errors when running the test module directly.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1586 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/othertests')
-rw-r--r--tests/othertests/templates.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py
index 86a67bea67..a92fc5ef00 100644
--- a/tests/othertests/templates.py
+++ b/tests/othertests/templates.py
@@ -8,7 +8,30 @@ from django.core.template import loader
from django.utils.translation import activate, deactivate, install
import traceback
-# Helper objects for template tests
+#################################
+# Custom template tag for tests #
+#################################
+
+register = template.Library()
+
+class EchoNode(template.Node):
+ def __init__(self, contents):
+ self.contents = contents
+
+ def render(self, context):
+ return " ".join(self.contents)
+
+def do_echo(parser, token):
+ return EchoNode(token.contents.split()[1:])
+
+register.tag("echo", do_echo)
+
+template.libraries['django.templatetags.testtags'] = register
+
+#####################################
+# Helper objects for template tests #
+#####################################
+
class SomeClass:
def __init__(self):
self.otherclass = OtherClass()