summaryrefslogtreecommitdiffstats
path: root/tests/test_directives
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test_directives/__init__.py0
-rw-r--r--tests/test_directives/test_directive_code.py (renamed from tests/test_directive_code.py)36
-rw-r--r--tests/test_directives/test_directive_object_description.py (renamed from tests/test_directive_object_description.py)0
-rw-r--r--tests/test_directives/test_directive_only.py (renamed from tests/test_directive_only.py)4
-rw-r--r--tests/test_directives/test_directive_option.py40
-rw-r--r--tests/test_directives/test_directive_other.py (renamed from tests/test_directive_other.py)0
-rw-r--r--tests/test_directives/test_directive_patch.py (renamed from tests/test_directive_patch.py)0
-rw-r--r--tests/test_directives/test_directives_no_typesetting.py (renamed from tests/test_directives_no_typesetting.py)0
8 files changed, 60 insertions, 20 deletions
diff --git a/tests/test_directives/__init__.py b/tests/test_directives/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/test_directives/__init__.py
diff --git a/tests/test_directive_code.py b/tests/test_directives/test_directive_code.py
index df7de57..2783d8f 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directives/test_directive_code.py
@@ -295,7 +295,7 @@ def test_LiteralIncludeReader_diff(testroot, literal_inc_path):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_code_block(app, status, warning):
- app.builder.build('index')
+ app.build(filenames=[app.srcdir / 'index.rst'])
et = etree_parse(app.outdir / 'index.xml')
secs = et.findall('./section/section')
code_block = secs[0].findall('literal_block')
@@ -311,13 +311,13 @@ def test_code_block(app, status, warning):
@pytest.mark.sphinx('html', testroot='directive-code')
def test_force_option(app, status, warning):
- app.builder.build(['force'])
+ app.build(filenames=[app.srcdir / 'force.rst'])
assert 'force.rst' not in warning.getvalue()
@pytest.mark.sphinx('html', testroot='directive-code')
def test_code_block_caption_html(app, status, warning):
- app.builder.build(['caption'])
+ app.build(filenames=[app.srcdir / 'caption.rst'])
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
caption = ('<div class="code-block-caption">'
'<span class="caption-number">Listing 1 </span>'
@@ -329,7 +329,7 @@ def test_code_block_caption_html(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_caption_latex(app, status, warning):
- app.builder.build_all()
+ app.build(force_all=True)
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}'
@@ -342,7 +342,7 @@ def test_code_block_caption_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_namedlink_latex(app, status, warning):
- app.builder.build_all()
+ app.build(force_all=True)
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}'
link1 = '\\hyperref[\\detokenize{caption:name-test-rb}]'\
@@ -359,7 +359,7 @@ def test_code_block_namedlink_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_emphasize_latex(app, status, warning):
- app.builder.build(['emphasize'])
+ app.build(filenames=[app.srcdir / 'emphasize.rst'])
latex = (app.outdir / 'python.tex').read_text(encoding='utf8').replace('\r\n', '\n')
includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26,}}%\n'
assert includes in latex
@@ -369,7 +369,7 @@ def test_code_block_emphasize_latex(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literal_include(app, status, warning):
- app.builder.build(['index'])
+ app.build(filenames=[app.srcdir / 'index.rst'])
et = etree_parse(app.outdir / 'index.xml')
secs = et.findall('./section/section')
literal_include = secs[1].findall('literal_block')
@@ -381,7 +381,7 @@ def test_literal_include(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literal_include_block_start_with_comment_or_brank(app, status, warning):
- app.builder.build(['python'])
+ app.build(filenames=[app.srcdir / 'python.rst'])
et = etree_parse(app.outdir / 'python.xml')
secs = et.findall('./section/section')
literal_include = secs[0].findall('literal_block')
@@ -405,7 +405,7 @@ def test_literal_include_block_start_with_comment_or_brank(app, status, warning)
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literal_include_linenos(app, status, warning):
- app.builder.build(['linenos'])
+ app.build(filenames=[app.srcdir / 'linenos.rst'])
html = (app.outdir / 'linenos.html').read_text(encoding='utf8')
# :linenos:
@@ -423,7 +423,7 @@ def test_literal_include_linenos(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_file_whole_of_emptyline(app, status, warning):
- app.builder.build_all()
+ app.build(force_all=True)
latex = (app.outdir / 'python.tex').read_text(encoding='utf8').replace('\r\n', '\n')
includes = (
'\\begin{sphinxVerbatim}'
@@ -437,7 +437,7 @@ def test_literalinclude_file_whole_of_emptyline(app, status, warning):
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literalinclude_caption_html(app, status, warning):
- app.builder.build_all()
+ app.build(force_all=True)
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
caption = ('<div class="code-block-caption">'
'<span class="caption-number">Listing 2 </span>'
@@ -449,7 +449,7 @@ def test_literalinclude_caption_html(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_caption_latex(app, status, warning):
- app.builder.build('index')
+ app.build(filenames='index')
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
@@ -462,7 +462,7 @@ def test_literalinclude_caption_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_namedlink_latex(app, status, warning):
- app.builder.build('index')
+ app.build(filenames='index')
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
link1 = '\\hyperref[\\detokenize{caption:name-test-py}]'\
@@ -479,7 +479,7 @@ def test_literalinclude_namedlink_latex(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literalinclude_classes(app, status, warning):
- app.builder.build(['classes'])
+ app.build(filenames=[app.srcdir / 'classes.rst'])
et = etree_parse(app.outdir / 'classes.xml')
secs = et.findall('./section/section')
@@ -496,7 +496,7 @@ def test_literalinclude_classes(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literalinclude_pydecorators(app, status, warning):
- app.builder.build(['py-decorators'])
+ app.build(filenames=[app.srcdir / 'py-decorators.rst'])
et = etree_parse(app.outdir / 'py-decorators.xml')
secs = et.findall('./section/section')
@@ -537,7 +537,7 @@ def test_literalinclude_pydecorators(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='directive-code')
def test_code_block_highlighted(app, status, warning):
- app.builder.build(['highlight'])
+ app.build(filenames=[app.srcdir / 'highlight.rst'])
doctree = app.env.get_doctree('highlight')
codeblocks = list(doctree.findall(nodes.literal_block))
@@ -549,7 +549,7 @@ def test_code_block_highlighted(app, status, warning):
@pytest.mark.sphinx('html', testroot='directive-code')
def test_linenothreshold(app, status, warning):
- app.builder.build(['linenothreshold'])
+ app.build(filenames=[app.srcdir / 'linenothreshold.rst'])
html = (app.outdir / 'linenothreshold.html').read_text(encoding='utf8')
# code-block using linenothreshold
@@ -570,7 +570,7 @@ def test_linenothreshold(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='directive-code')
def test_code_block_dedent(app, status, warning):
- app.builder.build(['dedent'])
+ app.build(filenames=[app.srcdir / 'dedent.rst'])
doctree = app.env.get_doctree('dedent')
codeblocks = list(doctree.findall(nodes.literal_block))
# Note: comparison string should not have newlines at the beginning or end
diff --git a/tests/test_directive_object_description.py b/tests/test_directives/test_directive_object_description.py
index f2c9f9d..f2c9f9d 100644
--- a/tests/test_directive_object_description.py
+++ b/tests/test_directives/test_directive_object_description.py
diff --git a/tests/test_directive_only.py b/tests/test_directives/test_directive_only.py
index 2e9ea63..bf03c7b 100644
--- a/tests/test_directive_only.py
+++ b/tests/test_directives/test_directive_only.py
@@ -34,7 +34,7 @@ def test_sectioning(app, status, warning):
'Unnumbered section: %r' % subsect[0]
testsects(prefix + str(i + 1) + '.', subsect, indent + 4)
- app.builder.build(['only'])
+ app.build(filenames=[app.srcdir / 'only.rst'])
doctree = app.env.get_doctree('only')
app.env.apply_post_transforms(doctree, 'only')
@@ -43,4 +43,4 @@ def test_sectioning(app, status, warning):
for i, s in enumerate(parts):
testsects(str(i + 1) + '.', s, 4)
assert len(parts) == 4, 'Expected 4 document level headings, got:\n%s' % \
- '\n'.join([p[0] for p in parts])
+ '\n'.join(p[0] for p in parts)
diff --git a/tests/test_directives/test_directive_option.py b/tests/test_directives/test_directive_option.py
new file mode 100644
index 0000000..76448cd
--- /dev/null
+++ b/tests/test_directives/test_directive_option.py
@@ -0,0 +1,40 @@
+import pytest
+
+
+@pytest.mark.sphinx('html', testroot='root',
+ confoverrides={'option_emphasise_placeholders': True})
+def test_option_emphasise_placeholders(app, status, warning):
+ app.build()
+ content = (app.outdir / 'objects.html').read_text(encoding='utf8')
+ assert '<em><span class="pre">TYPE</span></em>' in content
+ assert '{TYPE}' not in content
+ assert ('<em><span class="pre">WHERE</span></em>'
+ '<span class="pre">-</span>'
+ '<em><span class="pre">COUNT</span></em>' in content)
+ assert '<span class="pre">{{value}}</span>' in content
+ assert ('<span class="pre">--plugin.option</span></span>'
+ '<a class="headerlink" href="#cmdoption-perl-plugin.option" title="Link to this definition">¶</a></dt>') in content
+
+
+@pytest.mark.sphinx('html', testroot='root')
+def test_option_emphasise_placeholders_default(app, status, warning):
+ app.build()
+ content = (app.outdir / 'objects.html').read_text(encoding='utf8')
+ assert '<span class="pre">={TYPE}</span>' in content
+ assert '<span class="pre">={WHERE}-{COUNT}</span></span>' in content
+ assert '<span class="pre">{client_name}</span>' in content
+ assert ('<span class="pre">--plugin.option</span></span>'
+ '<span class="sig-prename descclassname"></span>'
+ '<a class="headerlink" href="#cmdoption-perl-plugin.option" title="Link to this definition">¶</a></dt>') in content
+
+
+@pytest.mark.sphinx('html', testroot='root')
+def test_option_reference_with_value(app, status, warning):
+ app.build()
+ content = (app.outdir / 'objects.html').read_text(encoding='utf-8')
+ assert ('<span class="pre">-mapi</span></span><span class="sig-prename descclassname">'
+ '</span><a class="headerlink" href="#cmdoption-git-commit-mapi"') in content
+ assert 'first option <a class="reference internal" href="#cmdoption-git-commit-mapi">' in content
+ assert ('<a class="reference internal" href="#cmdoption-git-commit-mapi">'
+ '<code class="xref std std-option docutils literal notranslate"><span class="pre">-mapi[=xxx]</span></code></a>') in content
+ assert '<span class="pre">-mapi</span> <span class="pre">with_space</span>' in content
diff --git a/tests/test_directive_other.py b/tests/test_directives/test_directive_other.py
index 1feb251..1feb251 100644
--- a/tests/test_directive_other.py
+++ b/tests/test_directives/test_directive_other.py
diff --git a/tests/test_directive_patch.py b/tests/test_directives/test_directive_patch.py
index f4eb8f9..f4eb8f9 100644
--- a/tests/test_directive_patch.py
+++ b/tests/test_directives/test_directive_patch.py
diff --git a/tests/test_directives_no_typesetting.py b/tests/test_directives/test_directives_no_typesetting.py
index fd101fb..fd101fb 100644
--- a/tests/test_directives_no_typesetting.py
+++ b/tests/test_directives/test_directives_no_typesetting.py