예제 #1
0
def test_simple_repr():
    assert repr(parse("{{ x }}")) == textwrap.dedent("""
    {
        x: {{x}}
    }
    {% program None %} ==> []
        {{ x }} ===> ['x']
    {% endprogram %}""")
예제 #2
0
def test_include5():
    assert repr(parse("""
    {% include "testdata/include2.html" %}
    """, os.path.join(BASEDIR, 'curdir'))) == textwrap.dedent("""
    {
        include2: {{include2}}
    }
    {% program None %} ==> []

    {% endprogram %}""")
예제 #3
0
def test_include():
    assert (
        parse(
            """
    {% include "./testdata/a-template.html" %}
    """,
            os.path.join(BASEDIR, "curdir"),
        ).fvars()
        == {"a"}
    )
예제 #4
0
def test_include3():
    assert (
        parse(
            """
    {% include "testdata/for-template.html" %}
    """,
            os.path.join(BASEDIR, "curdir"),
        ).fvars()
        == {"alist", "b", "c", "d", "e", "f"}
    )
예제 #5
0
def test_include5():
    assert (
        parse(
            """
    {% include "testdata/include1.html" %}
    """,
            os.path.join(BASEDIR, "curdir"),
        ).fvars()
        == {"include1", "include2"}
    )
예제 #6
0
def test_with2():
    assert (
        parse(
            """
    {% with foo.bar as x %}
        {{ x }} {{ y }}
    {% endwith %}
    """
        ).fvars()
        == {"foo", "y"}
    )
예제 #7
0
def test_for():
    assert (
        parse(
            u"""
    {% for a in alist %}
        {{ a }} {{ b }}
    {% endfor %}
    """
        ).fvars()
        == {"alist", "b"}
    )
예제 #8
0
def test_include2():
    assert (
        parse(
            """
    {% for a in alist %}
        {% include "testdata/a-template.html" %}
    {% endfor %}
    """,
            os.path.join(BASEDIR, "curdir"),
        ).fvars()
        == {"alist"}
    )
예제 #9
0
def test_if():
    assert (
        parse(
            """
    {% if a %}
        {{ b }}
    {% elif c == d %}
        {{ e }}
    {% else %}
        {{ f }}
    {% endif %}
    """
        ).fvars()
        == set("abcdef")
    )
예제 #10
0
def test_value():
    assert parse("{{ a }}").fvars() == {"a"}
예제 #11
0
def test_load():
    assert parse("{% load foo %}").fvars() == set()