~ubuntu-branches/ubuntu/karmic/python-docutils/karmic

« back to all changes in this revision

Viewing changes to test/test_writers/test_html4css1.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
# Author: reggie dugard
 
4
# Contact: reggie@users.sourceforge.net
 
5
# Revision: $Revision: 3968 $
 
6
# Date: $Date: 2005-10-29 14:28:44 +0200 (Sat, 29 Oct 2005) $
 
7
# Copyright: This module has been placed in the public domain.
 
8
 
 
9
"""
 
10
Test for fragment code in HTML writer.
 
11
 
 
12
Note: the 'body' and 'whole' entries have been removed from the parts
 
13
dictionaries (redundant), along with 'meta' and 'stylesheet' entries with
 
14
standard values, and any entries with empty values.
 
15
"""
 
16
 
 
17
from __init__ import DocutilsTestSupport
 
18
from docutils import core
 
19
 
 
20
def suite():
 
21
    s = DocutilsTestSupport.HtmlPublishPartsTestSuite()
 
22
    s.generateTests(totest)
 
23
    return s
 
24
 
 
25
 
 
26
totest = {}
 
27
 
 
28
totest['Title promotion'] = ({'stylesheet_path': '',
 
29
                              'embed_stylesheet': 0}, [
 
30
["""\
 
31
Simple String
 
32
""",
 
33
"""\
 
34
{'fragment': '''<p>Simple String</p>\\n''',
 
35
 'html_body': '''<div class="document">
 
36
<p>Simple String</p>
 
37
</div>\\n''',
 
38
 'html_head': '''...<title></title>\\n'''}
 
39
"""],
 
40
["""\
 
41
Simple String with *markup*
 
42
""",
 
43
"""\
 
44
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
 
45
 'html_body': '''<div class="document">
 
46
<p>Simple String with <em>markup</em></p>
 
47
</div>\\n''',
 
48
 'html_head': '''...<title></title>\\n'''}
 
49
"""],
 
50
["""\
 
51
Simple String with an even simpler ``inline literal``
 
52
""",
 
53
"""\
 
54
{'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>\\n''',
 
55
 'html_body': '''<div class="document">
 
56
<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>
 
57
</div>\\n''',
 
58
 'html_head': '''...<title></title>\\n'''}
 
59
"""],
 
60
["""\
 
61
A simple `anonymous reference`__
 
62
 
 
63
__ http://www.test.com/test_url
 
64
""",
 
65
"""\
 
66
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
 
67
 'html_body': '''<div class="document">
 
68
<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>
 
69
</div>\\n''',
 
70
 'html_head': '''...<title></title>\\n'''}
 
71
"""],
 
72
["""\
 
73
One paragraph.
 
74
 
 
75
Two paragraphs.
 
76
""",
 
77
"""\
 
78
{'fragment': '''<p>One paragraph.</p>
 
79
<p>Two paragraphs.</p>\\n''',
 
80
 'html_body': '''<div class="document">
 
81
<p>One paragraph.</p>
 
82
<p>Two paragraphs.</p>
 
83
</div>\\n''',
 
84
 'html_head': '''...<title></title>\\n'''}
 
85
"""],
 
86
["""\
 
87
A simple `named reference`_ with stuff in between the
 
88
reference and the target.
 
89
 
 
90
.. _`named reference`: http://www.test.com/test_url
 
91
""",
 
92
"""\
 
93
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
 
94
reference and the target.</p>\\n''',
 
95
 'html_body': '''<div class="document">
 
96
<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
 
97
reference and the target.</p>
 
98
</div>\\n''',
 
99
 'html_head': '''...<title></title>\\n'''}
 
100
"""],
 
101
["""\
 
102
+++++
 
103
Title
 
104
+++++
 
105
 
 
106
Subtitle
 
107
========
 
108
 
 
109
Some stuff
 
110
 
 
111
Section
 
112
-------
 
113
 
 
114
Some more stuff
 
115
 
 
116
Another Section
 
117
...............
 
118
 
 
119
And even more stuff
 
120
""",
 
121
"""\
 
122
{'fragment': '''<p>Some stuff</p>
 
123
<div class="section">
 
124
<h1><a id="section" name="section">Section</a></h1>
 
125
<p>Some more stuff</p>
 
126
<div class="section">
 
127
<h2><a id="another-section" name="another-section">Another Section</a></h2>
 
128
<p>And even more stuff</p>
 
129
</div>
 
130
</div>\\n''',
 
131
 'html_body': '''<div class="document" id="title">
 
132
<h1 class="title">Title</h1>
 
133
<h2 class="subtitle" id="subtitle">Subtitle</h2>
 
134
<p>Some stuff</p>
 
135
<div class="section">
 
136
<h1><a id="section" name="section">Section</a></h1>
 
137
<p>Some more stuff</p>
 
138
<div class="section">
 
139
<h2><a id="another-section" name="another-section">Another Section</a></h2>
 
140
<p>And even more stuff</p>
 
141
</div>
 
142
</div>
 
143
</div>\\n''',
 
144
 'html_head': '''...<title>Title</title>\\n''',
 
145
 'html_subtitle': '''<h2 class="subtitle" id="subtitle">Subtitle</h2>\\n''',
 
146
 'html_title': '''<h1 class="title">Title</h1>\\n''',
 
147
 'subtitle': '''Subtitle''',
 
148
 'title': '''Title'''}
 
149
"""],
 
150
["""\
 
151
+++++
 
152
Title
 
153
+++++
 
154
 
 
155
:author: me
 
156
 
 
157
Some stuff
 
158
""",
 
159
"""\
 
160
{'docinfo': '''<table class="docinfo" frame="void" rules="none">
 
161
<col class="docinfo-name" />
 
162
<col class="docinfo-content" />
 
163
<tbody valign="top">
 
164
<tr><th class="docinfo-name">Author:</th>
 
165
<td>me</td></tr>
 
166
</tbody>
 
167
</table>\\n''',
 
168
 'fragment': '''<p>Some stuff</p>\\n''',
 
169
 'html_body': '''<div class="document" id="title">
 
170
<h1 class="title">Title</h1>
 
171
<table class="docinfo" frame="void" rules="none">
 
172
<col class="docinfo-name" />
 
173
<col class="docinfo-content" />
 
174
<tbody valign="top">
 
175
<tr><th class="docinfo-name">Author:</th>
 
176
<td>me</td></tr>
 
177
</tbody>
 
178
</table>
 
179
<p>Some stuff</p>
 
180
</div>\\n''',
 
181
 'html_head': '''...<title>Title</title>
 
182
<meta name="author" content="me" />\\n''',
 
183
 'html_title': '''<h1 class="title">Title</h1>\\n''',
 
184
 'meta': '''<meta name="author" content="me" />\\n''',
 
185
 'title': '''Title'''}
 
186
"""]
 
187
])
 
188
 
 
189
totest['No title promotion'] = ({'doctitle_xform' : 0,
 
190
                                 'stylesheet_path': '',
 
191
                                 'embed_stylesheet': 0}, [
 
192
["""\
 
193
Simple String
 
194
""",
 
195
"""\
 
196
{'fragment': '''<p>Simple String</p>\\n''',
 
197
 'html_body': '''<div class="document">
 
198
<p>Simple String</p>
 
199
</div>\\n''',
 
200
 'html_head': '''...<title></title>\\n'''}
 
201
"""],
 
202
["""\
 
203
Simple String with *markup*
 
204
""",
 
205
"""\
 
206
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
 
207
 'html_body': '''<div class="document">
 
208
<p>Simple String with <em>markup</em></p>
 
209
</div>\\n''',
 
210
 'html_head': '''...<title></title>\\n'''}
 
211
"""],
 
212
["""\
 
213
Simple String with an even simpler ``inline literal``
 
214
""",
 
215
"""\
 
216
{'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>\\n''',
 
217
 'html_body': '''<div class="document">
 
218
<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>
 
219
</div>\\n''',
 
220
 'html_head': '''...<title></title>\\n'''}
 
221
"""],
 
222
["""\
 
223
A simple `anonymous reference`__
 
224
 
 
225
__ http://www.test.com/test_url
 
226
""",
 
227
"""\
 
228
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
 
229
 'html_body': '''<div class="document">
 
230
<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>
 
231
</div>\\n''',
 
232
 'html_head': '''...<title></title>\\n'''}
 
233
"""],
 
234
["""\
 
235
A simple `named reference`_ with stuff in between the
 
236
reference and the target.
 
237
 
 
238
.. _`named reference`: http://www.test.com/test_url
 
239
""",
 
240
"""\
 
241
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
 
242
reference and the target.</p>\\n''',
 
243
 'html_body': '''<div class="document">
 
244
<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
 
245
reference and the target.</p>
 
246
</div>\\n''',
 
247
 'html_head': '''...<title></title>\\n'''}
 
248
"""],
 
249
["""\
 
250
+++++
 
251
Title
 
252
+++++
 
253
 
 
254
Not A Subtitle
 
255
==============
 
256
 
 
257
Some stuff
 
258
 
 
259
Section
 
260
-------
 
261
 
 
262
Some more stuff
 
263
 
 
264
Another Section
 
265
...............
 
266
 
 
267
And even more stuff
 
268
""",
 
269
"""\
 
270
{'fragment': '''<div class="section">
 
271
<h1><a id="title" name="title">Title</a></h1>
 
272
<div class="section">
 
273
<h2><a id="not-a-subtitle" name="not-a-subtitle">Not A Subtitle</a></h2>
 
274
<p>Some stuff</p>
 
275
<div class="section">
 
276
<h3><a id="section" name="section">Section</a></h3>
 
277
<p>Some more stuff</p>
 
278
<div class="section">
 
279
<h4><a id="another-section" name="another-section">Another Section</a></h4>
 
280
<p>And even more stuff</p>
 
281
</div>
 
282
</div>
 
283
</div>
 
284
</div>\\n''',
 
285
 'html_body': '''<div class="document">
 
286
<div class="section">
 
287
<h1><a id="title" name="title">Title</a></h1>
 
288
<div class="section">
 
289
<h2><a id="not-a-subtitle" name="not-a-subtitle">Not A Subtitle</a></h2>
 
290
<p>Some stuff</p>
 
291
<div class="section">
 
292
<h3><a id="section" name="section">Section</a></h3>
 
293
<p>Some more stuff</p>
 
294
<div class="section">
 
295
<h4><a id="another-section" name="another-section">Another Section</a></h4>
 
296
<p>And even more stuff</p>
 
297
</div>
 
298
</div>
 
299
</div>
 
300
</div>
 
301
</div>\\n''',
 
302
 'html_head': '''...<title></title>\\n'''}
 
303
"""],
 
304
["""\
 
305
* bullet
 
306
* list
 
307
""",
 
308
"""\
 
309
{'fragment': '''<ul class="simple">
 
310
<li>bullet</li>
 
311
<li>list</li>
 
312
</ul>\\n''',
 
313
 'html_body': '''<div class="document">
 
314
<ul class="simple">
 
315
<li>bullet</li>
 
316
<li>list</li>
 
317
</ul>
 
318
</div>\\n''',
 
319
 'html_head': '''...<title></title>\\n'''}
 
320
"""],
 
321
["""\
 
322
Not a docinfo.
 
323
 
 
324
:This: .. _target:
 
325
 
 
326
       is
 
327
:a:
 
328
:simple:
 
329
:field: list
 
330
""",
 
331
"""\
 
332
{'fragment': '''<p>Not a docinfo.</p>
 
333
<table class="docutils field-list" frame="void" rules="none">
 
334
<col class="field-name" />
 
335
<col class="field-body" />
 
336
<tbody valign="top">
 
337
<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
 
338
</td>
 
339
</tr>
 
340
<tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
 
341
</tr>
 
342
<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
 
343
</tr>
 
344
<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
 
345
</tr>
 
346
</tbody>
 
347
</table>\\n''',
 
348
 'html_body': '''<div class="document">
 
349
<p>Not a docinfo.</p>
 
350
<table class="docutils field-list" frame="void" rules="none">
 
351
<col class="field-name" />
 
352
<col class="field-body" />
 
353
<tbody valign="top">
 
354
<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
 
355
</td>
 
356
</tr>
 
357
<tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
 
358
</tr>
 
359
<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
 
360
</tr>
 
361
<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
 
362
</tr>
 
363
</tbody>
 
364
</table>
 
365
</div>\\n''',
 
366
 'html_head': '''...<title></title>\\n'''}
 
367
"""],
 
368
])
 
369
 
 
370
 
 
371
if __name__ == '__main__':
 
372
    import unittest
 
373
    unittest.main(defaultTest='suite')