diff options
author | Matthew Fernandez <matthew.fernandez@gmail.com> | 2017-10-15 00:34:48 +0300 |
---|---|---|
committer | Matthew Fernandez <matthew.fernandez@gmail.com> | 2017-10-19 04:39:56 +0300 |
commit | 6553b2ed32e6ccf50ae852d470fd1684d0628941 (patch) | |
tree | 8eed7006631bee119c3e7fda6c77519de19c2a43 /tests/test_ext_todo.py | |
parent | ed4949e00008311587dc57a3e84e203920f7af00 (diff) |
add a test that confirms #1020
Diffstat (limited to 'tests/test_ext_todo.py')
-rw-r--r-- | tests/test_ext_todo.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_ext_todo.py b/tests/test_ext_todo.py index 77d657adc..4f01a07ab 100644 --- a/tests/test_ext_todo.py +++ b/tests/test_ext_todo.py @@ -84,3 +84,31 @@ def test_todo_not_included(app, status, warning): # check handled event assert len(todos) == 2 assert set(todo[1].astext() for todo in todos) == set(['todo in foo', 'todo in bar']) + +@pytest.mark.sphinx('latex', testroot='ext-todo', freshenv=True, + confoverrides={'todo_include_todos': True, 'todo_emit_warnings': True}) +def test_todo_valid_link(app, status, warning): + """ + Test that the inserted "original entry" links for todo items have a target + that exists in the LaTeX output. The target was previously incorrectly + omitted (GitHub issue #1020). + """ + + # Ensure the LaTeX output is built. + app.builder.build_all() + + content = (app.outdir / 'TodoTests.tex').text() + + # Look for the link to foo. We could equally well look for the link to bar. + link = r'\{\\hyperref\[\\detokenize\{(.*?foo.*?)}]\{\\sphinxcrossref{' \ + r'\\sphinxstyleemphasis{original entry}}}}' + m = re.findall(link, content) + assert len(m) == 1 + target = m[0] + + # Look for the targets of this link. + labels = [m for m in re.findall(r'\\label\{([^}]*)}', content) + if m == target] + + # If everything is correct we should have exactly one target. + assert len(labels) == 1 |