Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_build
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
Test all builders.
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2016-01-14 15:54:04 -06:00
|
|
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
2008-12-27 05:19:17 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
"""
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
from six import BytesIO
|
|
|
|
|
2016-01-26 10:27:05 -06:00
|
|
|
import pickle
|
|
|
|
from docutils import nodes
|
2012-05-01 01:13:06 -05:00
|
|
|
from textwrap import dedent
|
2016-01-03 05:26:38 -06:00
|
|
|
from sphinx.errors import SphinxError
|
2016-06-11 10:00:52 -05:00
|
|
|
import sphinx.builders.linkcheck
|
2009-09-08 05:07:27 -05:00
|
|
|
|
2016-07-13 11:10:57 -05:00
|
|
|
from util import with_app, with_tempdir, rootdir, tempdir, SkipTest, TestApp
|
2014-09-21 10:17:02 -05:00
|
|
|
|
2014-07-12 08:14:14 -05:00
|
|
|
try:
|
|
|
|
from docutils.writers.manpage import Writer as ManWriter
|
|
|
|
except ImportError:
|
|
|
|
ManWriter = None
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2008-08-04 16:48:12 -05:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
class MockOpener(object):
|
|
|
|
def open(self, req, **kwargs):
|
|
|
|
class result(BytesIO):
|
|
|
|
headers = None
|
|
|
|
url = req.url
|
|
|
|
return result()
|
2009-02-21 10:17:21 -06:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
sphinx.builders.linkcheck.opener = MockOpener()
|
2009-12-28 10:09:09 -06:00
|
|
|
|
2010-01-17 09:48:02 -06:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
def verify_build(buildername, srcdir):
|
|
|
|
if buildername == 'man' and ManWriter is None:
|
2014-07-12 08:14:14 -05:00
|
|
|
raise SkipTest('man writer is not available')
|
2014-09-21 10:17:02 -05:00
|
|
|
app = TestApp(buildername=buildername, srcdir=srcdir)
|
2013-09-28 07:51:20 -05:00
|
|
|
try:
|
2014-09-21 10:17:02 -05:00
|
|
|
app.builder.build_all()
|
|
|
|
finally:
|
2014-07-12 20:44:48 -05:00
|
|
|
app.cleanup()
|
2014-08-18 20:44:09 -05:00
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_build_all():
|
|
|
|
# If supported, build in a non-ASCII source dir
|
|
|
|
test_name = u'\u65e5\u672c\u8a9e'
|
|
|
|
try:
|
|
|
|
srcdir = tempdir / test_name
|
|
|
|
(rootdir / 'root').copytree(tempdir / test_name)
|
|
|
|
except UnicodeEncodeError:
|
|
|
|
srcdir = tempdir / 'all'
|
|
|
|
else:
|
|
|
|
# add a doc with a non-ASCII file name to the source dir
|
|
|
|
(srcdir / (test_name + '.txt')).write_text(dedent("""
|
|
|
|
nonascii file name page
|
|
|
|
=======================
|
|
|
|
"""))
|
|
|
|
|
|
|
|
master_doc = srcdir / 'contents.txt'
|
2015-12-19 03:57:40 -06:00
|
|
|
master_doc.write_text(master_doc.text() + dedent(u"""
|
2014-09-21 10:17:02 -05:00
|
|
|
.. toctree::
|
|
|
|
|
|
|
|
%(test_name)s/%(test_name)s
|
|
|
|
""" % {'test_name': test_name})
|
2015-12-19 03:57:40 -06:00
|
|
|
)
|
2014-09-21 10:17:02 -05:00
|
|
|
|
|
|
|
# note: no 'html' - if it's ok with dirhtml it's ok with html
|
2015-01-15 07:17:01 -06:00
|
|
|
for buildername in ['dirhtml', 'singlehtml', 'latex', 'texinfo', 'pickle',
|
2016-08-15 02:32:38 -05:00
|
|
|
'json', 'text', 'htmlhelp', 'qthelp', 'epub2', 'epub',
|
2015-01-15 07:17:01 -06:00
|
|
|
'applehelp', 'changes', 'xml', 'pseudoxml', 'man',
|
|
|
|
'linkcheck']:
|
2014-09-21 10:17:02 -05:00
|
|
|
yield verify_build, buildername, srcdir
|
|
|
|
|
|
|
|
|
2016-07-13 11:10:57 -05:00
|
|
|
@with_tempdir
|
|
|
|
def test_master_doc_not_found(tmpdir):
|
|
|
|
(tmpdir / 'conf.py').write_text('master_doc = "index"')
|
|
|
|
assert tmpdir.listdir() == ['conf.py']
|
|
|
|
|
2016-01-03 05:26:38 -06:00
|
|
|
try:
|
2016-07-13 11:10:57 -05:00
|
|
|
app = TestApp(buildername='dummy', srcdir=tmpdir)
|
2016-01-03 05:26:38 -06:00
|
|
|
app.builder.build_all()
|
|
|
|
assert False # SphinxError not raised
|
|
|
|
except Exception as exc:
|
|
|
|
assert isinstance(exc, SphinxError)
|
2016-01-03 05:52:39 -06:00
|
|
|
finally:
|
2016-07-13 11:10:57 -05:00
|
|
|
app.cleanup()
|
2016-01-03 05:26:38 -06:00
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app(buildername='text', testroot='circular')
|
|
|
|
def test_circular_toctree(app, status, warning):
|
2014-08-18 20:44:09 -05:00
|
|
|
app.builder.build_all()
|
2014-09-21 10:17:02 -05:00
|
|
|
warnings = warning.getvalue()
|
2014-10-09 09:53:33 -05:00
|
|
|
assert (
|
|
|
|
'circular toctree references detected, ignoring: '
|
|
|
|
'sub <- contents <- sub') in warnings
|
|
|
|
assert (
|
|
|
|
'circular toctree references detected, ignoring: '
|
|
|
|
'contents <- sub <- contents') in warnings
|
2014-08-18 20:44:09 -05:00
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app(buildername='text', testroot='numbered-circular')
|
|
|
|
def test_numbered_circular_toctree(app, status, warning):
|
2014-08-18 20:44:09 -05:00
|
|
|
app.builder.build_all()
|
2014-09-21 10:17:02 -05:00
|
|
|
warnings = warning.getvalue()
|
2014-10-09 09:53:33 -05:00
|
|
|
assert (
|
|
|
|
'circular toctree references detected, ignoring: '
|
|
|
|
'sub <- contents <- sub') in warnings
|
|
|
|
assert (
|
|
|
|
'circular toctree references detected, ignoring: '
|
|
|
|
'contents <- sub <- contents') in warnings
|
2016-01-26 10:27:05 -06:00
|
|
|
|
|
|
|
|
2016-01-26 10:36:43 -06:00
|
|
|
@with_app(buildername='dummy', testroot='image-glob')
|
2016-01-26 10:27:05 -06:00
|
|
|
def test_image_glob(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
|
|
|
# index.rst
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
|
|
|
|
|
|
|
|
assert isinstance(doctree[0][1], nodes.image)
|
|
|
|
assert doctree[0][1]['candidates'] == {'*': 'rimg.png'}
|
|
|
|
assert doctree[0][1]['uri'] == 'rimg.png'
|
|
|
|
|
|
|
|
assert isinstance(doctree[0][2], nodes.figure)
|
|
|
|
assert isinstance(doctree[0][2][0], nodes.image)
|
|
|
|
assert doctree[0][2][0]['candidates'] == {'*': 'rimg.png'}
|
|
|
|
assert doctree[0][2][0]['uri'] == 'rimg.png'
|
|
|
|
|
|
|
|
assert isinstance(doctree[0][3], nodes.image)
|
|
|
|
assert doctree[0][3]['candidates'] == {'application/pdf': 'img.pdf',
|
|
|
|
'image/gif': 'img.gif',
|
|
|
|
'image/png': 'img.png'}
|
|
|
|
assert doctree[0][3]['uri'] == 'img.*'
|
|
|
|
|
|
|
|
assert isinstance(doctree[0][4], nodes.figure)
|
|
|
|
assert isinstance(doctree[0][4][0], nodes.image)
|
|
|
|
assert doctree[0][4][0]['candidates'] == {'application/pdf': 'img.pdf',
|
|
|
|
'image/gif': 'img.gif',
|
|
|
|
'image/png': 'img.png'}
|
|
|
|
assert doctree[0][4][0]['uri'] == 'img.*'
|
|
|
|
|
|
|
|
# subdir/index.rst
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'subdir/index.doctree').bytes())
|
|
|
|
|
|
|
|
assert isinstance(doctree[0][1], nodes.image)
|
2016-01-26 10:36:43 -06:00
|
|
|
assert doctree[0][1]['candidates'] == {'*': 'subdir/rimg.png'}
|
|
|
|
assert doctree[0][1]['uri'] == 'subdir/rimg.png'
|
|
|
|
|
|
|
|
assert isinstance(doctree[0][2], nodes.image)
|
|
|
|
assert doctree[0][2]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf',
|
2016-01-26 10:27:05 -06:00
|
|
|
'image/svg+xml': 'subdir/svgimg.svg'}
|
2016-01-26 10:36:43 -06:00
|
|
|
assert doctree[0][2]['uri'] == 'subdir/svgimg.*'
|
2016-01-26 10:27:05 -06:00
|
|
|
|
2016-01-26 10:36:43 -06:00
|
|
|
assert isinstance(doctree[0][3], nodes.figure)
|
|
|
|
assert isinstance(doctree[0][3][0], nodes.image)
|
|
|
|
assert doctree[0][3][0]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf',
|
2016-01-26 10:27:05 -06:00
|
|
|
'image/svg+xml': 'subdir/svgimg.svg'}
|
2016-01-26 10:36:43 -06:00
|
|
|
assert doctree[0][3][0]['uri'] == 'subdir/svgimg.*'
|