summaryrefslogtreecommitdiff
path: root/tests/test_directive_code.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-01-26 01:53:24 +0900
committerGitHub <noreply@github.com>2021-01-26 01:53:24 +0900
commit2ee0338388a54e976c3776c116cdc1080fb62c53 (patch)
tree16ca1cf2a9c423b62d9705202ca22f0dcda4a90a /tests/test_directive_code.py
parent77fad1ec9826a6e3751030ea719be04acd9519c3 (diff)
parent84dc65ad51ee91e1073ff9b99b207753843f387c (diff)
downloadsphinx-git-2ee0338388a54e976c3776c116cdc1080fb62c53.tar.gz
Merge pull request #7942 from tk0miya/7879_default_setting_of_html_codeblock_linenos_style
html: html_codeblock_linenos_style defaults to 'inline' (refs: #7849)
Diffstat (limited to 'tests/test_directive_code.py')
-rw-r--r--tests/test_directive_code.py94
1 files changed, 19 insertions, 75 deletions
diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py
index 0ae11baf3..a011a31e8 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directive_code.py
@@ -423,44 +423,16 @@ def test_literal_include_linenos(app, status, warning):
html = (app.outdir / 'linenos.html').read_text()
# :linenos:
- assert ('<td class="linenos"><div class="linenodiv"><pre>'
- ' 1\n'
- ' 2\n'
- ' 3\n'
- ' 4\n'
- ' 5\n'
- ' 6\n'
- ' 7\n'
- ' 8\n'
- ' 9\n'
- '10\n'
- '11\n'
- '12\n'
- '13</pre></div></td>' in html)
+ assert ('<span class="linenos"> 1</span><span class="c1">'
+ '# Literally included file using Python highlighting</span>' in html)
# :lineno-start:
- assert ('<td class="linenos"><div class="linenodiv"><pre>'
- '200\n'
- '201\n'
- '202\n'
- '203\n'
- '204\n'
- '205\n'
- '206\n'
- '207\n'
- '208\n'
- '209\n'
- '210\n'
- '211\n'
- '212</pre></div></td>' in html)
-
- # :lineno-match:
- assert ('<td class="linenos"><div class="linenodiv"><pre>'
- '5\n'
- '6\n'
- '7\n'
- '8\n'
- '9</pre></div></td>' in html)
+ assert ('<span class="linenos">200</span><span class="c1">'
+ '# Literally included file using Python highlighting</span>' in html)
+
+ # :lines: 5-9
+ assert ('<span class="linenos">5</span><span class="k">class</span> '
+ '<span class="nc">Foo</span><span class="p">:</span>' in html)
@pytest.mark.sphinx('latex', testroot='directive-code')
@@ -594,45 +566,17 @@ def test_linenothreshold(app, status, warning):
app.builder.build(['linenothreshold'])
html = (app.outdir / 'linenothreshold.html').read_text()
- lineos_head = '<td class="linenos"><div class="linenodiv"><pre>'
- lineos_tail = '</pre></div></td>'
-
# code-block using linenothreshold
- _, matched, html = html.partition(lineos_head +
- '1\n'
- '2\n'
- '3\n'
- '4\n'
- '5\n'
- '6' + lineos_tail)
- assert matched
-
- # code-block not using linenothreshold
- html, matched, _ = html.partition(lineos_head +
- '1\n'
- '2' + lineos_tail)
- assert not matched
+ assert ('<span class="linenos">1</span><span class="k">class</span> '
+ '<span class="nc">Foo</span><span class="p">:</span>' in html)
+
+ # code-block not using linenothreshold (no line numbers)
+ assert '<span></span><span class="c1"># comment</span>' in html
# literal include using linenothreshold
- _, matched, html = html.partition(lineos_head +
- ' 1\n'
- ' 2\n'
- ' 3\n'
- ' 4\n'
- ' 5\n'
- ' 6\n'
- ' 7\n'
- ' 8\n'
- ' 9\n'
- '10\n'
- '11\n'
- '12\n'
- '13' + lineos_tail)
- assert matched
-
- # literal include not using linenothreshold
- html, matched, _ = html.partition(lineos_head +
- '1\n'
- '2\n'
- '3' + lineos_tail)
- assert not matched
+ assert ('<span class="linenos"> 1</span><span class="c1">'
+ '# Literally included file using Python highlighting</span>' in html)
+
+ # literal include not using linenothreshold (no line numbers)
+ assert ('<span></span><span class="c1"># Very small literal include '
+ '(linenothreshold check)</span>' in html)