34
33
self.assertTrue('bzrlib.doc_generate.builders.texinfo'
35
34
in conf.extensions)
37
class TestSphinx(tests.TestCaseInTempDir):
39
def make_sphinx(self):
40
out = tests.StringIOWrapper()
41
err = tests.StringIOWrapper()
42
app = application.Sphinx(
43
'.', confdir=os.path.dirname(conf.__file__), outdir='.',
45
buildername='texinfo',
47
status=out, warning=err,
51
def build(self, app, all_files=True, file_names=None):
52
if file_names is None:
54
app.build(all_files, file_names)
56
# FIXME: something smells wrong here as we can't process a single file
57
# alone. On top of that, it seems the doc tree must contain an index.txt
58
# file. We may need a texinfo builder ? -- vila 20100505
60
def create_content(self, content):
61
"""Put content into a single file.
63
This is appropriate for simple tests about the content of a single file.
65
app, out, err = self.make_sphinx()
66
self.build_tree_contents([('index.txt', content),])
69
def assertContent(self, expected, end=None):
70
"""Check the content of the file created with creste_content().
72
Most texinfo constructs can be tested this way without caring for any
73
boilerplate that texinfo may require at the beginning or the end of the
77
# By default we test constructs that are embedded into a paragraph
78
# which always end with two \n (even if the input has none)
80
self.assertFileEqual(expected + end, 'index.texi')
83
class TestBuilderLoaded(TestSphinx):
36
class TestBuilderLoaded(test_dg.TestSphinx):
85
38
def test_builder_loaded(self):
86
39
app, out, err = self.make_sphinx()
87
40
self.assertTrue('texinfo' in app.builderclasses)
90
class TestTextGeneration(TestSphinx):
92
def test_special_chars(self):
93
self.create_content("A '@' a '{' and a '}'")
94
self.assertContent("A '@@' a '@{' and a '@}'")
96
def test_emphasis(self):
97
self.create_content('*important*')
98
self.assertContent('@emph{important}')
100
def test_strong(self):
101
self.create_content('**very important**')
102
self.assertContent('@strong{very important}')
104
def test_literal(self):
105
self.create_content('the command is ``foo``')
106
self.assertContent('the command is @code{foo}')
108
def test_paragraphs(self):
109
self.create_content('''\
114
self.assertContent('''\
117
This is another one.''')
119
def test_literal_block(self):
120
self.create_content('''\
126
self.assertContent('''\
135
def test_block_quote(self):
136
self.create_content('''\
137
This is an ordinary paragraph, introducing a block quote.
139
"It is my business to know things. That is my trade."
141
This is another ordinary paragraph.
143
self.assertContent('''\
144
This is an ordinary paragraph, introducing a block quote.
147
"It is my business to know things. That is my trade."
151
This is another ordinary paragraph.
154
# examples are not followed by an empty line
158
class TestDocumentAttributesGeneration(TestSphinx):
160
def test_title(self):
161
self.create_content('''\
166
self.assertContent('@chapter Bazaar Release Notes\n', end='')
169
class TestListGeneration(TestSphinx):
171
def test_bullet_list(self):
172
self.create_content('''\
173
* This is a bulleted list.
174
* It has two items, the second
177
self.assertContent('''\
180
This is a bulleted list.
183
It has two items, the second
190
def test_enumerated_list(self):
191
self.create_content('''\
192
#. This is a numbered list.
193
#. It has two items, the second
196
self.assertContent('''\
199
This is a numbered list.
202
It has two items, the second
210
class TestTableGeneration(TestSphinx):
212
def test_table(self):
213
self.create_content('''\
214
=========== ================
216
=========== ================
220
=========== ================
222
# FIXME: Sphinx bug ? Why are tables enclosed in a block_quote
223
# (translated as an @example).
224
self.assertContent('''\
226
@multitable {xxxxxxxxxxx}{xxxxxxxxxxxxxxxx}
227
@headitem Prefix @tab Description
238
class TestTocTreeGeneration(TestSphinx):
240
def test_toctree(self):
241
self.build_tree_contents(
249
bzr 0.0.8 <bzr-0.0.8>
251
('bzr-0.0.8.txt', """
259
* Adding a file whose parent directory is not versioned will
260
implicitly add the parent, and so on up to the root.
263
app, out, err = self.make_sphinx()
265
self.assertFileEqual("""\
266
@chapter Table of Contents
268
* bzr 0.0.8: (bzr-0.0.8.info)bzr 0.0.8.
272
self.assertFileEqual("""\
274
@section Improvements
277
Adding a file whose parent directory is not versioned will
278
implicitly add the parent, and so on up to the root.
284
class TestSections(TestSphinx):
286
def test_sections(self):
287
self.create_content('''\
292
Chapter introduction.
304
The first subsection.
309
The second subsection.
314
Here is sus sub section one.
319
Far tooo deep to get a name
324
No idea how to call that, but sphinx says it's a paragraph.
326
self.assertContent('''\
328
Chapter introduction.
333
@subsection subsection one
334
The first subsection.
336
@subsection subsection two
337
The second subsection.
339
@subsubsection subsubsection one
340
Here is sus sub section one.
343
Far tooo deep to get a name
346
No idea how to call that, but sphinx says it's a paragraph.''')
349
class TestFileProduction(TestSphinx):
43
class TestFileProduction(test_dg.TestSphinx):
351
45
def test_files_generated(self):
352
46
self.build_tree_contents(