summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2017-07-08 09:04:29 -0700
committerDavid Lord <davidism@gmail.com>2017-07-08 09:04:29 -0700
commit34ca7f17c26ddb1bbdf7b59384fb5e96e66070e7 (patch)
treecabbc36c9931a6eb13d8f47b40cbb58ff2ecb6e1 /tests
parent10fc8afc15b973ed3e547508e2bc160c3fbf8966 (diff)
downloadjinja2-34ca7f17c26ddb1bbdf7b59384fb5e96e66070e7.tar.gz
add test and changelog
use ignore_case function
Diffstat (limited to 'tests')
-rw-r--r--tests/test_filters.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/tests/test_filters.py b/tests/test_filters.py
index 2ef3249..f323f76 100644
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -45,16 +45,16 @@ class TestFilter(object):
)
assert tmpl.render(given='yes') == 'no|False|no|yes'
- def test_dictsort(self, env):
- tmpl = env.from_string(
- '{{ foo|dictsort }}|'
- '{{ foo|dictsort(true) }}|'
- '{{ foo|dictsort(false, "value") }}'
- )
- out = tmpl.render(foo={"aa": 0, "b": 1, "c": 2, "AB": 3})
- assert out == ("[('aa', 0), ('AB', 3), ('b', 1), ('c', 2)]|"
- "[('AB', 3), ('aa', 0), ('b', 1), ('c', 2)]|"
- "[('aa', 0), ('b', 1), ('c', 2), ('AB', 3)]")
+ @pytest.mark.parametrize('args,expect', (
+ ('', "[('aa', 0), ('AB', 3), ('b', 1), ('c', 2)]"),
+ ('true', "[('AB', 3), ('aa', 0), ('b', 1), ('c', 2)]"),
+ ('by="value"', "[('aa', 0), ('b', 1), ('c', 2), ('AB', 3)]"),
+ ('reverse=true', "[('c', 2), ('b', 1), ('AB', 3), ('aa', 0)]")
+ ))
+ def test_dictsort(self, env, args, expect):
+ t = env.from_string('{{{{ foo|dictsort({args}) }}}}'.format(args=args))
+ out = t.render(foo={"aa": 0, "b": 1, "c": 2, "AB": 3})
+ assert out == expect
def test_batch(self, env):
tmpl = env.from_string("{{ foo|batch(3)|list }}|"