summaryrefslogtreecommitdiffstats
path: root/tests/test_util_template.py
blob: 4601179c1d67688a15e37d500c659b1a62b1a746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Tests sphinx.util.template functions."""

from sphinx.util.template import ReSTRenderer


def test_ReSTRenderer_escape():
    r = ReSTRenderer()
    template = '{{ "*hello*" | e }}'
    assert r.render_string(template, {}) == r'\*hello\*'


def test_ReSTRenderer_heading():
    r = ReSTRenderer()

    template = '{{ "hello" | heading }}'
    assert r.render_string(template, {}) == 'hello\n====='

    template = '{{ "hello" | heading(1) }}'
    assert r.render_string(template, {}) == 'hello\n====='

    template = '{{ "русский язык" | heading(2) }}'
    assert r.render_string(template, {}) == ('русский язык\n'
                                             '------------')

    # language: ja
    r.env.language = 'ja'
    template = '{{ "русский язык" | heading }}'
    assert r.render_string(template, {}) == ('русский язык\n'
                                             '=======================')