summaryrefslogtreecommitdiffstats
path: root/tests/test_util_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_util_template.py')
-rw-r--r--tests/test_util_template.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_util_template.py b/tests/test_util_template.py
new file mode 100644
index 0000000..4601179
--- /dev/null
+++ b/tests/test_util_template.py
@@ -0,0 +1,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'
+ '=======================')