diff options
author | Matthew Woodcraft <matthew@woodcraft.me.uk> | 2017-11-05 22:47:57 +0000 |
---|---|---|
committer | Matthew Woodcraft <matthew@woodcraft.me.uk> | 2017-11-05 22:51:38 +0000 |
commit | 6b15c9c1c738c587a73b4144e8fe2b0d3b8aa4b4 (patch) | |
tree | 702b13b7ba56c16850ecdf76001dc55bc0c298af /tests/test_build_text.py | |
parent | f46c91b6529932d0c1201cde208c01e964f289d1 (diff) | |
download | sphinx-git-6b15c9c1c738c587a73b4144e8fe2b0d3b8aa4b4.tar.gz |
#3998: Add optional section numbering in plain text output
Controlled by new config values: text_add_secnumbers and
text_secnumber_suffix.
Diffstat (limited to 'tests/test_build_text.py')
-rw-r--r-- | tests/test_build_text.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test_build_text.py b/tests/test_build_text.py index 81e354ecd..6e9aec4b6 100644 --- a/tests/test_build_text.py +++ b/tests/test_build_text.py @@ -110,3 +110,57 @@ def test_list_items_in_admonition(app, status, warning): assert lines[2] == " * item 1" assert lines[3] == "" assert lines[4] == " * item 2" + + +@with_text_app() +def test_secnums(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'doc2.txt').text(encoding='utf8') + expect = ( + "Section B\n" + "*********\n" + "\n" + "\n" + "Sub Ba\n" + "======\n" + "\n" + "\n" + "Sub Bb\n" + "======\n" + ) + assert result == expect + + app.config.text_add_secnumbers = True + app.builder.build_all() + result = (app.outdir / 'doc2.txt').text(encoding='utf8') + expect = ( + "2. Section B\n" + "************\n" + "\n" + "\n" + "2.1. Sub Ba\n" + "===========\n" + "\n" + "\n" + "2.2. Sub Bb\n" + "===========\n" + ) + assert result == expect + + app.config.text_secnumber_suffix = " " + app.builder.build_all() + result = (app.outdir / 'doc2.txt').text(encoding='utf8') + expect = ( + "2 Section B\n" + "***********\n" + "\n" + "\n" + "2.1 Sub Ba\n" + "==========\n" + "\n" + "\n" + "2.2 Sub Bb\n" + "==========\n" + ) + assert result == expect + |