コード例 #1
0
ファイル: Compiler_test.py プロジェクト: bukzor/yelp_cheetah
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
ファイル: Compiler_test.py プロジェクト: struys/yelp_cheetah
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'
コード例 #3
0
def test_compile_multiple_files_by_directory(template_writer, tmpdir):
    tmpl1 = template_writer.write('foo')
    tmpl2 = template_writer.write('bar')
    compile_all([tmpdir.strpath])
    assert run_python(tmpl1.replace('.tmpl', '.py')) == 'foo'
    assert run_python(tmpl2.replace('.tmpl', '.py')) == 'bar'
コード例 #4
0
def test_compile_multiple_files(template_writer):
    tmpl1 = template_writer.write('foo')
    tmpl2 = template_writer.write('bar')
    compile_all([tmpl1, tmpl2])
    assert run_python(tmpl1.replace('.tmpl', '.py')) == 'foo'
    assert run_python(tmpl2.replace('.tmpl', '.py')) == 'bar'
コード例 #5
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'
コード例 #6
0
def test_compile_multiple_files_by_directory(template_writer, tmpdir):
    tmpl1 = template_writer.write('foo')
    tmpl2 = template_writer.write('bar')
    compile_all([tmpdir.strpath])
    assert run_python(tmpl1.replace('.tmpl', '.py')) == 'foo'
    assert run_python(tmpl2.replace('.tmpl', '.py')) == 'bar'
コード例 #7
0
def test_compile_multiple_files(template_writer):
    tmpl1 = template_writer.write('foo')
    tmpl2 = template_writer.write('bar')
    compile_all([tmpl1, tmpl2])
    assert run_python(tmpl1.replace('.tmpl', '.py')) == 'foo'
    assert run_python(tmpl2.replace('.tmpl', '.py')) == 'bar'
コード例 #8
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'