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:
parent
4e7006856d
commit
63cf85b64d
|
@ -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()
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue