Skip to content

Commit

Permalink
Rename some of the templatetag libs in test app.
Browse files Browse the repository at this point in the history
The new names are more consistent.
  • Loading branch information
miracle2k committed Aug 22, 2011
1 parent 3e4fd34 commit edbc0f2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_nodes_and_extensions():
assert env.from_string('a{% foo_ex %}b').render() == 'a{my_foo}b'

# Django tags, loaded from a Coffin library
assert Template('{% load foo_tag %}a{% foo_coffin %}b').render(Context()) == 'a{foo}b'
assert Template('{% load django_tags %}a{% foo_coffin %}b').render(Context()) == 'a{foo}b'


def test_filters():
Expand All @@ -38,26 +38,26 @@ def test_filters():

# Filter registered with a Coffin library is available in Django and Jinja2
assert env.from_string('a{{ "b"|foo }}c').render() == 'a{foo}c'
assert Template('{% load foo_filter %}a{{ "b"|foo }}c').render(Context()) == 'a{foo}c'
assert Template('{% load portable_filters %}a{{ "b"|foo }}c').render(Context()) == 'a{foo}c'

# Filter registered with a Django library is also available in Jinja2
Template('{% load foo_filter_django %}{{ "b"|foo_django }}').render(Context())
Template('{% load django_library %}{{ "b"|foo_django }}').render(Context())
assert env.from_string('a{{ "b"|foo }}c').render() == 'a{foo}c'

# Some filters, while registered with a Coffin library, are only
# available in Jinja2:
# - when using @environmentfilter
env.from_string('{{ "b"|environment }}')
assert_raises(Exception, Template, '{% load jinjafilters %}{{ "b"|environment }}')
assert_raises(Exception, Template, '{% load jinja2_filters %}{{ "b"|environment }}')
# - when using @contextfilter
env.from_string('{{ "b"|context }}')
assert_raises(Exception, Template, '{% load jinjafilters %}{{ "b"|context }}')
assert_raises(Exception, Template, '{% load jinja2_filters %}{{ "b"|context }}')
# - when requiring more than one argument
env.from_string('{{ "b"|multiarg(1,2) }}')
assert_raises(Exception, Template, '{% load jinjafilters %}{{ "b"|multiarg }}')
assert_raises(Exception, Template, '{% load jinja2_filters %}{{ "b"|multiarg }}')
# - when Jinja2-exclusivity is explicitly requested
env.from_string('{{ "b"|jinja_forced }}')
assert_raises(Exception, Template, '{% load jinjafilters %}{{ "b"|jinja_forced }}')
assert_raises(Exception, Template, '{% load jinja2_filters %}{{ "b"|jinja_forced }}')
# [bug] Jinja2-exclusivity caused the compatibility layer to be not
# applied, causing for example safe strings to be escaped.
assert env.from_string('{{ "><"|django_jinja_forced }}').render() == '><'
Expand Down Expand Up @@ -124,4 +124,4 @@ def test_filter_compat_other():
# The Django filters can handle "Undefined" values
assert env.from_string('{{ doesnotexist|django_raw_output }}').render() == ''

# TODO: test @stringfilter
# TODO: test @stringfilter

0 comments on commit edbc0f2

Please sign in to comment.