def gen_text(env: TextIOBase, package: str, tmpl: str): """Create output from Jinja template.""" if env: env_args = json_datetime.load(env) else: env_args = {} jinja_env = template.setup(package) echo(jinja_env.get_template(tmpl).render(**env_args))
def test_custom_filter_fallthrough(filter_, args, kwargs, expected): env = template.setup('jnrbase') assert env.filters[filter_](*args, **kwargs) == expected
def test_custom_filter(filter_, args, kwargs, expected, monkeypatch): monkeypatch.setattr('sys.stdout.isatty', lambda: True) env = template.setup('jnrbase') assert env.filters[filter_](*args, **kwargs) == expected
def test_setup(): env = template.setup('jnrbase') assert 'safe' in env.filters
def test_custom_filter_fallthrough(filter, args, kwargs, expected, stdout): stdout.isatty.side_effect = lambda: False env = template.setup('jnrbase') expect(env.filters[filter](*args, **kwargs)) == expected
def test_custom_filter(filter, args, kwargs, expected): env = template.setup('jnrbase') expect(env.filters[filter](*args, **kwargs)) == expected
def test_setup(): env = template.setup('jnrbase') expect(env.filters).contains('safe')