summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-02-09 02:05:09 +0900
committerGitHub <noreply@github.com>2019-02-09 02:05:09 +0900
commita844ce0f2fa46cb67d5cbff5f42a44396ee66aaa (patch)
tree62462e309e8bd6d275916a1bcd648b7d6bfb56f1
parent5cca8407b5e48df0d5f8caf3bfb97fa92ad85122 (diff)
parent1d5e3cba0e2c50d71f28a24361373af1d58c7766 (diff)
downloadsphinx-git-a844ce0f2fa46cb67d5cbff5f42a44396ee66aaa.tar.gz
Merge pull request #6038 from tk0miya/refactor_test_docutilsconf
refactor: test-docutilsconf
-rw-r--r--tests/roots/test-docutilsconf/conf.py4
-rw-r--r--tests/roots/test-docutilsconf/index.rst6
-rw-r--r--tests/roots/test-docutilsconf/index.txt15
-rw-r--r--tests/test_docutilsconf.py86
4 files changed, 20 insertions, 91 deletions
diff --git a/tests/roots/test-docutilsconf/conf.py b/tests/roots/test-docutilsconf/conf.py
index d7f27e6e1..e69de29bb 100644
--- a/tests/roots/test-docutilsconf/conf.py
+++ b/tests/roots/test-docutilsconf/conf.py
@@ -1,4 +0,0 @@
-project = 'Sphinx docutils conf <Tests>'
-source_suffix = '.txt'
-keep_warnings = True
-exclude_patterns = ['_build']
diff --git a/tests/roots/test-docutilsconf/index.rst b/tests/roots/test-docutilsconf/index.rst
new file mode 100644
index 000000000..d292e3227
--- /dev/null
+++ b/tests/roots/test-docutilsconf/index.rst
@@ -0,0 +1,6 @@
+test-docutilsconf
+==================
+
+Sphinx [1]_
+
+.. [1] Python Documentation Generator
diff --git a/tests/roots/test-docutilsconf/index.txt b/tests/roots/test-docutilsconf/index.txt
deleted file mode 100644
index b20204e61..000000000
--- a/tests/roots/test-docutilsconf/index.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-docutils conf
-=============
-
-field-name-limit
-----------------
-
-:short: desc
-:long long long long: long title
-
-option-limit
-------------
-
---short short desc
---long-long-long-long long desc
-
diff --git a/tests/test_docutilsconf.py b/tests/test_docutilsconf.py
index 57ae785db..a8cfde7ef 100644
--- a/tests/test_docutilsconf.py
+++ b/tests/test_docutilsconf.py
@@ -8,88 +8,30 @@
:license: BSD, see LICENSE for details.
"""
-import re
-
import pytest
+from docutils import nodes
-from sphinx.testing.path import path
+from sphinx.testing.util import assert_node
from sphinx.util.docutils import patch_docutils
-def regex_count(expr, result):
- return len(re.findall(expr, result))
-
-
-@pytest.mark.sphinx('html', testroot='docutilsconf', freshenv=True, docutilsconf='')
+@pytest.mark.sphinx('dummy', testroot='docutilsconf')
def test_html_with_default_docutilsconf(app, status, warning):
with patch_docutils(app.confdir):
- app.builder.build(['contents'])
+ app.build()
- result = (app.outdir / 'index.html').text()
+ doctree = app.env.get_doctree('index')
+ assert_node(doctree[0][1], [nodes.paragraph, ("Sphinx ",
+ [nodes.footnote_reference, "1"])])
- assert regex_count(r'<th class="field-name">', result) == 1
- assert regex_count(r'<th class="field-name" colspan="2">', result) == 1
- assert regex_count(r'<td class="option-group">', result) == 1
- assert regex_count(r'<td class="option-group" colspan="2">', result) == 1
-
-@pytest.mark.sphinx('html', testroot='docutilsconf', freshenv=True, docutilsconf=(
- '\n[html4css1 writer]'
- '\noption-limit:1'
- '\nfield-name-limit:1'
- '\n')
-)
+@pytest.mark.sphinx('dummy', testroot='docutilsconf',
+ docutilsconf=('[restructuredtext parser]\n'
+ 'trim_footnote_reference_space: true\n'))
def test_html_with_docutilsconf(app, status, warning):
with patch_docutils(app.confdir):
- app.builder.build(['contents'])
-
- result = (app.outdir / 'index.html').text()
-
- assert regex_count(r'<th class="field-name">', result) == 0
- assert regex_count(r'<th class="field-name" colspan="2">', result) == 2
- assert regex_count(r'<td class="option-group">', result) == 0
- assert regex_count(r'<td class="option-group" colspan="2">', result) == 2
+ app.build()
-
-@pytest.mark.sphinx('html', testroot='docutilsconf')
-def test_html(app, status, warning):
- with patch_docutils(app.confdir):
- app.builder.build(['contents'])
- assert warning.getvalue() == ''
-
-
-@pytest.mark.sphinx('latex', testroot='docutilsconf')
-def test_latex(app, status, warning):
- with patch_docutils(app.confdir):
- app.builder.build(['contents'])
- assert warning.getvalue() == ''
-
-
-@pytest.mark.sphinx('man', testroot='docutilsconf')
-def test_man(app, status, warning):
- with patch_docutils(app.confdir):
- app.builder.build(['contents'])
- assert warning.getvalue() == ''
-
-
-@pytest.mark.sphinx('texinfo', testroot='docutilsconf')
-def test_texinfo(app, status, warning):
- with patch_docutils(app.confdir):
- app.builder.build(['contents'])
-
-
-@pytest.mark.sphinx('html', testroot='docutilsconf',
- docutilsconf='[general]\nsource_link=true\n')
-def test_docutils_source_link_with_nonascii_file(app, status, warning):
- srcdir = path(app.srcdir)
- mb_name = '\u65e5\u672c\u8a9e'
- try:
- (srcdir / (mb_name + '.txt')).write_text('')
- except UnicodeEncodeError:
- from sphinx.testing.path import FILESYSTEMENCODING
- raise pytest.skip.Exception(
- 'nonascii filename not supported on this filesystem encoding: '
- '%s', FILESYSTEMENCODING)
-
- with patch_docutils(app.confdir):
- app.builder.build_all()
+ doctree = app.env.get_doctree('index')
+ assert_node(doctree[0][1], [nodes.paragraph, ("Sphinx",
+ [nodes.footnote_reference, "1"])])