예제 #1
0
def test_markdown():
    path = "./files/md_template.j2"

    output = cli.render(path, {"content": "#Test"}, [], markdown=True)
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')
    assert output == "<h1>Test</h1>\n"
예제 #2
0
def test_relative_path():
    path = "./files/template.j2"

    output = cli.render(path, {"title": "Test"}, [])
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')
    assert output == "Test"
예제 #3
0
def test_relative_path():
    path = "./files/template.j2"

    output = cli.render(path, {"title": "Test"}, [])
    if isinstance(output, cli.text_type):
        output = output.encode("utf-8")
    assert output == b"Test"
예제 #4
0
def test_relative_path():
    path = "./files/template.j2"

    title = b"\xc3\xb8".decode("utf8")
    output = cli.render(path, {"title": title}, [])
    assert output == title
    assert type(output) == cli.text_type
예제 #5
0
def test_absolute_path():
    absolute_base_path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(absolute_base_path, "files", "template.j2")

    output = cli.render(path, {"title": "Test"}, [])
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')
    assert output == "Test"
예제 #6
0
def test_absolute_path():
    absolute_base_path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(absolute_base_path, "files", "template.j2")

    title = b"\xc3\xb8".decode("utf8")
    output = cli.render(path, {"title": title}, [])
    assert output == title
    assert type(output) == cli.text_type
예제 #7
0
def test_recursive():
    path = "./files/recursive_template.j2"
    data = {'sitename': 'SiteName', 'title': 'Welcome to {{ sitename }}'}
    recursive_result_path = "./files/recursive_template_recursive_result.html"

    output = cli.render(path, data, [], False, True)
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')

    with open(recursive_result_path) as f:
        expected_result = f.read()
        assert output == expected_result
예제 #8
0
파일: tests.py 프로젝트: lgtml/jinja2-cli
def relative_path_test():
    path = "./files/template.j2"

    output = cli.render(path, {"title": "Test"})
    assert output == "Test"
예제 #9
0
파일: tests.py 프로젝트: lgtml/jinja2-cli
def absolute_path_test():
    absolute_base_path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(absolute_base_path, "files", "template.j2")

    output = cli.render(path, {"title": "Test"})
    assert output == "Test"