summaryrefslogtreecommitdiff
path: root/tests/test_build_text.py
diff options
context:
space:
mode:
authorMatthew Woodcraft <matthew@woodcraft.me.uk>2017-11-07 23:10:11 +0000
committerMatthew Woodcraft <matthew@woodcraft.me.uk>2017-11-07 23:10:11 +0000
commit604db47228689c512fd5f7eb75669b1a0f30e867 (patch)
treeeb8ba76ac02e9fe7223b2132a26b6970e0a7ec24 /tests/test_build_text.py
parent7fac34bb44282d26af0ba67fbda7544ccf53c33f (diff)
downloadsphinx-git-604db47228689c512fd5f7eb75669b1a0f30e867.tar.gz
#3998: Toctree section numbering in plain text output
Diffstat (limited to 'tests/test_build_text.py')
-rw-r--r--tests/test_build_text.py51
1 files changed, 45 insertions, 6 deletions
diff --git a/tests/test_build_text.py b/tests/test_build_text.py
index 6e9aec4b6..2651f35ce 100644
--- a/tests/test_build_text.py
+++ b/tests/test_build_text.py
@@ -115,7 +115,20 @@ def test_list_items_in_admonition(app, status, warning):
@with_text_app()
def test_secnums(app, status, warning):
app.builder.build_all()
- result = (app.outdir / 'doc2.txt').text(encoding='utf8')
+ contents = (app.outdir / 'contents.txt').text(encoding='utf8')
+ expect = (
+ "* Section A\n"
+ "\n"
+ "* Section B\n"
+ "\n"
+ " * Sub Ba\n"
+ "\n"
+ " * Sub Bb\n"
+ "\n"
+ "* 日本語\n"
+ )
+ assert contents == expect
+ doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
expect = (
"Section B\n"
"*********\n"
@@ -128,11 +141,24 @@ def test_secnums(app, status, warning):
"Sub Bb\n"
"======\n"
)
- assert result == expect
+ assert doc2 == expect
app.config.text_add_secnumbers = True
app.builder.build_all()
- result = (app.outdir / 'doc2.txt').text(encoding='utf8')
+ contents = (app.outdir / 'contents.txt').text(encoding='utf8')
+ expect = (
+ "* 1. Section A\n"
+ "\n"
+ "* 2. Section B\n"
+ "\n"
+ " * 2.1. Sub Ba\n"
+ "\n"
+ " * 2.2. Sub Bb\n"
+ "\n"
+ "* 3. 日本語\n"
+ )
+ assert contents == expect
+ doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
expect = (
"2. Section B\n"
"************\n"
@@ -145,11 +171,24 @@ def test_secnums(app, status, warning):
"2.2. Sub Bb\n"
"===========\n"
)
- assert result == expect
+ assert doc2 == expect
app.config.text_secnumber_suffix = " "
app.builder.build_all()
- result = (app.outdir / 'doc2.txt').text(encoding='utf8')
+ contents = (app.outdir / 'contents.txt').text(encoding='utf8')
+ expect = (
+ "* 1 Section A\n"
+ "\n"
+ "* 2 Section B\n"
+ "\n"
+ " * 2.1 Sub Ba\n"
+ "\n"
+ " * 2.2 Sub Bb\n"
+ "\n"
+ "* 3 日本語\n"
+ )
+ assert contents == expect
+ doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
expect = (
"2 Section B\n"
"***********\n"
@@ -162,5 +201,5 @@ def test_secnums(app, status, warning):
"2.2 Sub Bb\n"
"==========\n"
)
- assert result == expect
+ assert doc2 == expect