From c613b3a509f061885304d0b82834c6865cbfe4ce Mon Sep 17 00:00:00 2001 From: Yujun Zhang Date: Sat, 22 Apr 2017 14:15:13 +0800 Subject: Add support for render a justified output from list and dict Change-Id: I4411e62b3d1a067cfa8ae1296cf521877aedb830 Signed-off-by: Yujun Zhang --- tests/unit/reporter/filters_test.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/unit/reporter') 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 -- cgit 1.2.3-korg