Fix #4701: viewcode: Misplaced `<div>` in viewcode html output

This commit is contained in:
Takeshi KOMIYA
2018-03-05 23:46:34 +09:00
parent 8e0cca01e5
commit f1c6c22e84
3 changed files with 13 additions and 1 deletions

View File

@@ -38,6 +38,17 @@ def test_viewcode(app, status, warning):
# the next assert fails, until the autodoc bug gets fixed
assert result.count('this is the class attribute class_attr') == 2
result = (app.outdir / '_modules/spam/mod1.html').text(encoding='utf-8')
result = re.sub('<span class=".*?">', '<span>', result) # filter pygments classes
assert ('<div class="viewcode-block" id="Class1"><a class="viewcode-back" '
'href="../../index.html#spam.Class1">[docs]</a>'
'<span>@decorator</span>\n'
'<span>class</span> <span>Class1</span>'
'<span>(</span><span>object</span><span>):</span>\n'
' <span>&quot;&quot;&quot;</span>\n'
'<span> this is Class1</span>\n'
'<span> &quot;&quot;&quot;</span></div>\n') in result
@pytest.mark.sphinx(testroot='ext-viewcode', tags=['test_linkcode'])
def test_linkcode(app, status, warning):