aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-22 14:15:13 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-24 08:51:48 +0800
commitc613b3a509f061885304d0b82834c6865cbfe4ce (patch)
tree1c80db5108605a277e6469a15438a8cc88d6a8a3 /tests
parent40c29df6796e6d055f35b730e70dac87ab7db2d4 (diff)
Add support for render a justified output from list and dict
Change-Id: I4411e62b3d1a067cfa8ae1296cf521877aedb830 Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/reporter/filters_test.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/unit/reporter/filters_test.py b/tests/unit/reporter/filters_test.py
index 2ced9304..ab96e554 100644
--- a/tests/unit/reporter/filters_test.py
+++ b/tests/unit/reporter/filters_test.py
@@ -7,13 +7,19 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from jinja2 import Environment
+import pytest
from qtip.reporter import filters
-from jinja2 import Environment
-def test_justify():
+@pytest.mark.parametrize('template, content, output', [
+ ('{{ content|justify(width=6) }}', [('k1', 'v1'), ('k2', 'v2')], 'k1..v1\nk2..v2'),
+ ('{{ content|justify(width=6) }}', ('k1', 'v1'), 'k1..v1'),
+ ('{{ content|justify(width=6) }}', {'k1': 'v1'}, 'k1..v1')
+])
+def test_justify(template, content, output):
env = Environment()
env.filters['justify'] = filters.justify
- template = env.from_string('{{ kvpair|justify(width=10) }}')
- assert template.render(kvpair=('key', 'value')) == 'key..value'
+ template = env.from_string(template)
+ assert template.render(content=content) == output