diff options
author | BALaka-18 <balaka2605@gmail.com> | 2021-02-22 21:26:22 +0530 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2021-02-24 17:16:01 -0800 |
commit | 73a94e00d4376da11966fd6add5bdd469b59b0da (patch) | |
tree | b3a871c116173cce7bf3c3b999c0f85e10cfd01e /tests | |
parent | ab9cd8c66426c753df7ea3a952ffa6f8f8619b2e (diff) | |
download | jinja2-73a94e00d4376da11966fd6add5bdd469b59b0da.tar.gz |
map filter can use False as default
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_filters.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_filters.py b/tests/test_filters.py index 3cd0fdd..efc82bc 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -666,6 +666,12 @@ class TestFilter: tmpl = env.from_string( '{{ users|map(attribute="lastname", default="smith")|join(", ") }}' ) + test_list = env.from_string( + '{{ users|map(attribute="lastname", default=["smith","x"])|join(", ") }}' + ) + test_str = env.from_string( + '{{ users|map(attribute="lastname", default="")|join(", ") }}' + ) users = [ Fullname("john", "lennon"), Fullname("jane", "edwards"), @@ -673,6 +679,8 @@ class TestFilter: Firstname("mike"), ] assert tmpl.render(users=users) == "lennon, edwards, None, smith" + assert test_list.render(users=users) == "lennon, edwards, None, ['smith', 'x']" + assert test_str.render(users=users) == "lennon, edwards, None, " def test_simple_select(self, env): env = Environment() |