Debian Codegraph @

t/unit/contrib/test_sphinx.py

raw
1 import os
2
3 import pytest
4
5 try:
6 from sphinx.application import Sphinx # noqa
7 from sphinx_testing import TestApp
8 sphinx_installed = True
9 except ImportError:
10 sphinx_installed = False
11
12
13 SRCDIR = os.path.join(os.path.dirname(__file__), 'proj')
14
15
16 @pytest.mark.skipif(
17 sphinx_installed is False,
18 reason='Sphinx is not installed'
19 )
20 def test_sphinx():
21 app = TestApp(srcdir=SRCDIR, confdir=SRCDIR)
22 app.build()
23 contents = open(os.path.join(app.outdir, 'contents.html'),
24 encoding='utf-8').read()
25 assert 'This is a sample Task' in contents
26 assert 'This is a sample Shared Task' in contents
27 assert (
28 'This task is in a different module!'
29 not in contents
30 )
31 # Verify :task: cross-reference role resolves to a link
32 assert 'foo.bar' in contents
33 assert 'Cross-reference test' in contents