Пример #1
0
def test_templates_runnable_using_env(tmpdir):
    tmpl_filename = os.path.join(tmpdir.strpath, 'my_template.tmpl')
    tmpl_py_filename = os.path.join(tmpdir.strpath, 'my_template.py')

    with io.open(tmpl_filename, 'w') as template:
        template.write('$foo\n' '$bar\n')

    compile_template(tmpl_filename)

    ret = run_python(tmpl_py_filename, env={'foo': 'herp', 'bar': 'derp'})
    assert ret.strip() == 'herp\nderp'
Пример #2
0
def test_templates_runnable_using_env(tmpdir):
    tmpl_filename = os.path.join(tmpdir.strpath, 'my_template.tmpl')
    tmpl_py_filename = os.path.join(tmpdir.strpath, 'my_template.py')

    with io.open(tmpl_filename, 'w') as template:
        template.write(
            '$foo\n'
            '$bar\n'
        )

    compile_template(tmpl_filename)

    ret = run_python(tmpl_py_filename, env={'foo': 'herp', 'bar': 'derp'})
    assert ret.strip() == 'herp\nderp'
def _test_compile_template(tmpl_file):
    tmpl_py = compile_template(tmpl_file)
    assert os.path.exists(tmpl_py)
    ret = run_python(tmpl_py)
    assert ret == 'Hello world'
Пример #4
0
def _test_compile_template(tmpl_file):
    tmpl_py = compile_template(tmpl_file)
    assert os.path.exists(tmpl_py)
    ret = run_python(tmpl_py)
    assert ret == 'Hello world'