Skip to content

Commit

Permalink
Merge branch 'master' into pull-django-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
miracle2k committed Mar 10, 2010
2 parents 972041a + 0df8f0b commit 220f6bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/test_defaultfilters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from datetime import datetime, date
from nose.tools import assert_raises
from coffin.common import env


def r(s, context={}):
from coffin.common import env
return env.from_string(s).render(context)


Expand Down Expand Up @@ -40,6 +40,7 @@ def test_floatformat():


def test_date_stuff():
from coffin.common import env
assert r('a{{ d|date("Y") }}b', {'d': date(2007, 01, 01)}) == 'a2007b'
assert r('a{{ d|time("H") }}b', {'d': datetime(2007, 01, 01, 12, 01, 01)}) == 'a12b'
# TODO: timesince, timeuntil
Expand Down
8 changes: 6 additions & 2 deletions tests/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from nose.tools import assert_raises

from coffin.common import env
from jinja2 import TemplateAssertionError as Jinja2TemplateAssertionError
from django.template import Template, Context, \
TemplateSyntaxError as DjangoTemplateSyntaxError
Expand All @@ -12,7 +11,9 @@
def test_nodes_and_extensions():
"""Test availability of registered nodes/extensions.
"""
# Jinja2 extensions, loaded from a Coffin library
from coffin.common import env

# Jinja2 extensions, loaded from a Coffin library
assert env.from_string('a{% foo %}b').render() == 'a{foo}b'

# Django tags, loaded from a Coffin library
Expand Down Expand Up @@ -54,6 +55,7 @@ def test_filters():
def test_filter_compat_safestrings():
"""Test filter compatibility layer with respect to safe strings.
"""
from coffin.common import env
env.autoescape = True

# Jinja-style safe output strings are considered "safe" by both engines
Expand All @@ -77,6 +79,7 @@ def test_filter_compat_escapetrings():
"""Test filter compatibility layer with respect to strings flagged as
"wanted for escaping".
"""
from coffin.common import env
env.autoescape = False

# Django-style "force escaping" works in both engines
Expand All @@ -88,6 +91,7 @@ def test_filter_compat_other():
"""Test other features of the filter compatibility layer.
"""
# A Django filter with @needs_autoescape works in Jinja2
from coffin.common import env
env.autoescape = True
assert env.from_string('{{ "b"|needing_autoescape }}').render() == 'True'
env.autoescape = False
Expand Down
4 changes: 2 additions & 2 deletions tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
``coffin.template.library``, ``coffin.template.defaultfilters`` and
``coffin.template.defaulttags`` have their own test modules.
"""



def test_template_class():
from coffin.template import Template
from coffin.common import env

# initializing a template directly uses Coffin's Jinja
# environment - we know it does if our tags are available.
Expand Down

0 comments on commit 220f6bb

Please sign in to comment.