1
# Copyright (C) 2010 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Documentation generation tests."""
20
from bzrlib import tests
21
from bzrlib.doc_generate import (
22
# FIXME: doc/en/conf.py should be used here, or rather merged into
23
# bzrlib/doc_generate/conf.py -- vila 20100429
26
from bzrlib.tests import features
29
def load_tests(basic_tests, module, loader):
30
suite = loader.suiteClass()
31
# add the tests for this module
32
suite.addTests(basic_tests)
38
# add the tests for the sub modules
39
suite.addTests(loader.loadTestsFromModuleNames(
40
['bzrlib.tests.doc_generate.' + name
41
for name in testmod_names]))
46
class TestSphinx(tests.TestCaseInTempDir):
47
"""Base class for sphinx tests.
49
This is used for both the builder and the writer until a better solution is
50
found to test at a lower level.
53
_test_needs_features = [features.sphinx]
55
def make_sphinx(self):
56
out = tests.StringIOWrapper()
57
err = tests.StringIOWrapper()
58
from sphinx import application
59
app = application.Sphinx(
60
'.', confdir=os.path.dirname(conf.__file__), outdir='.',
62
buildername='texinfo',
64
status=out, warning=err,
68
def build(self, app, all_files=True, file_names=None):
69
if file_names is None:
71
app.build(all_files, file_names)
73
# FIXME: something smells wrong here as we can't process a single file
74
# alone. On top of that, it seems the doc tree must contain an index.txt
75
# file. We may need a texinfo builder ? -- vila 20100505
77
def create_content(self, content):
78
"""Put content into a single file.
80
This is appropriate for simple tests about the content of a single file.
82
app, out, err = self.make_sphinx()
83
self.build_tree_contents([('index.txt', content),])
86
def assertContent(self, expected, header=None, end=None):
87
"""Check the content of the file created with creste_content().
89
Most texinfo constructs can be tested this way without caring for any
90
boilerplate that texinfo may require at the beginning or the end of the
96
This file has been converted using a beta rst->texinfo converter.
97
Most of the info links are currently bogus, don't report bugs about them,
98
this is currently worked on.
103
# By default we test constructs that are embedded into a paragraph
104
# which always end with two \n (even if the input has none)
106
self.assertFileEqual(header + expected + end, 'index.texi')