Beispiel #1
0
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))
Beispiel #2
0
def test_custom_filter_fallthrough(filter_, args, kwargs, expected):
    env = template.setup('jnrbase')
    assert env.filters[filter_](*args, **kwargs) == expected
Beispiel #3
0
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
Beispiel #4
0
def test_setup():
    env = template.setup('jnrbase')
    assert 'safe' in env.filters
Beispiel #5
0
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
Beispiel #6
0
def test_custom_filter(filter, args, kwargs, expected):
    env = template.setup('jnrbase')
    expect(env.filters[filter](*args, **kwargs)) == expected
Beispiel #7
0
def test_setup():
    env = template.setup('jnrbase')
    expect(env.filters).contains('safe')