Hi!

I decided to try to unit test templatetag using following code:

    import unittest
    from django import template
    from django.template import loader

    register = template.Library()

    @register.simple_tag
    def sometag(arg=None):
        return "ok"


    class MyTagTests(unittest.TestCase):
        def setUp(self):
            self.context = template.Context()

        def test_sometag(self):
            """Test the tag"""

            template_content = """
                {% sometag "some string" %}
            """

            #print
loader.get_template_from_string(template_content).render(self.context)
            print
template.Template(template_content).render(self.context)


    if __name__ == '__main__':
        unittest.main()

But I keep getting "TemplateSyntaxError: Invalid block tag: 'sometag'"

As a reference I've been looking on to this
http://code.djangoproject.com/browser/django/trunk/tests/othertests/templates.py?rev=3113
only difference I can see is the test_template_loader() function, but
is that it? I should also do template_loader to get the tag tests? I
would like to know what is the simplest way to do this, there got to
be a way to test these without custom template loader...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to