示例#1
0
def test_get_template():
    target = Target(
        template_name='foo.txt.tpl',
        filename='foo{{ x }}.txt',
        scopes={},
    )
    environment = Environment(loader=DictLoader({
        'foo.txt.tpl': 'foo {{ x }}',
    }))
    target_template = target.get_template(environment)
    assert target_template.template.render({'x': 42}) == 'foo 42'
    assert target_template.filename_template.render({'x': 42}) == 'foo42.txt'
示例#2
0
def test_get_template():
    target = Target(template_name="foo.txt.tpl", filename="foo{{ x }}.txt", scopes={})
    environment = Environment(loader=DictLoader({"foo.txt.tpl": "foo {{ x }}"}))
    target_template = target.get_template(environment)
    assert target_template.template.render({"x": 42}) == "foo 42"
    assert target_template.filename_template.render({"x": 42}) == "foo42.txt"