refactor: test_ext_todo

This commit is contained in:
Takeshi KOMIYA 2019-03-24 17:32:08 +09:00
parent 2adeb68af1
commit ab268c3138

View File

@ -30,23 +30,19 @@ def test_todo(app, status, warning):
# check todolist # check todolist
content = (app.outdir / 'index.html').text() content = (app.outdir / 'index.html').text()
html = ('<p class="admonition-title">Todo</p>\n' assert ('<p class="admonition-title">Todo</p>\n'
'<p>todo in foo</p>') '<p>todo in foo</p>') in content
assert re.search(html, content, re.S)
html = ('<p class="admonition-title">Todo</p>\n' assert ('<p class="admonition-title">Todo</p>\n'
'<p>todo in bar</p>') '<p>todo in bar</p>') in content
assert re.search(html, content, re.S)
# check todo # check todo
content = (app.outdir / 'foo.html').text() content = (app.outdir / 'foo.html').text()
html = ('<p class="admonition-title">Todo</p>\n' assert ('<p class="admonition-title">Todo</p>\n'
'<p>todo in foo</p>') '<p>todo in foo</p>') in content
assert re.search(html, content, re.S)
html = ('<p class="admonition-title">Todo</p>\n' assert ('<p class="admonition-title">Todo</p>\n'
'<p>todo in param field</p>') '<p>todo in param field</p>') in content
assert re.search(html, content, re.S)
# check emitted warnings # check emitted warnings
assert 'WARNING: TODO entry found: todo in foo' in warning.getvalue() assert 'WARNING: TODO entry found: todo in foo' in warning.getvalue()
@ -72,19 +68,16 @@ def test_todo_not_included(app, status, warning):
# check todolist # check todolist
content = (app.outdir / 'index.html').text() content = (app.outdir / 'index.html').text()
html = ('<p class="admonition-title">Todo</p>\n' assert ('<p class="admonition-title">Todo</p>\n'
'<p>todo in foo</p>') '<p>todo in foo</p>') not in content
assert not re.search(html, content, re.S)
html = ('<p class="admonition-title">Todo</p>\n' assert ('<p class="admonition-title">Todo</p>\n'
'<p>todo in bar</p>') '<p>todo in bar</p>') not in content
assert not re.search(html, content, re.S)
# check todo # check todo
content = (app.outdir / 'foo.html').text() content = (app.outdir / 'foo.html').text()
html = ('<p class="admonition-title">Todo</p>\n' assert ('<p class="admonition-title">Todo</p>\n'
'<p>todo in foo</p>') '<p>todo in foo</p>') not in content
assert not re.search(html, content, re.S)
# check emitted warnings # check emitted warnings
assert 'WARNING: TODO entry found: todo in foo' in warning.getvalue() assert 'WARNING: TODO entry found: todo in foo' in warning.getvalue()
@ -114,8 +107,8 @@ def test_todo_valid_link(app, status, warning):
# Look for the link to foo. Note that there are two of them because the # Look for the link to foo. Note that there are two of them because the
# source document uses todolist twice. We could equally well look for links # source document uses todolist twice. We could equally well look for links
# to bar. # to bar.
link = r'\{\\hyperref\[\\detokenize\{(.*?foo.*?)}]\{\\sphinxcrossref{' \ link = (r'\{\\hyperref\[\\detokenize\{(.*?foo.*?)}]\{\\sphinxcrossref{'
r'\\sphinxstyleemphasis{original entry}}}}' r'\\sphinxstyleemphasis{original entry}}}}')
m = re.findall(link, content) m = re.findall(link, content)
assert len(m) == 4 assert len(m) == 4
target = m[0] target = m[0]