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
This commit is contained in:
Adrian Holovaty 2005-12-09 04:29:20 +00:00
parent 4e7006856d
commit 63cf85b64d
3 changed files with 24 additions and 18 deletions

View File

@ -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()

View File

@ -1,17 +0,0 @@
# Custom tag library used in conjunction with template tests
from django.core import template
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)