1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
#!/usr/bin/python
# Author: reggie dugard
# Contact: reggie@users.sourceforge.net
# Revision: $Revision: 1.6 $
# Date: $Date: 2004/11/08 15:30:11 $
# Copyright: This module has been placed in the public domain.
"""
Test for fragment code in HTML writer.
Note: the 'body' and 'whole' entries have been removed from the parts
dictionaries (redundant), along with 'meta' and 'stylesheet' entries with
standard values, and any entries with empty values.
"""
from __init__ import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.HtmlPublishPartsTestSuite()
s.generateTests(totest)
return s
totest = {}
totest['Title promotion'] = ({}, [
["""\
Simple String
""",
"""\
{'fragment': '''<p>Simple String</p>\\n'''}
"""
],
["""\
Simple String with *markup*
""",
"""\
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n'''}
"""
],
["""\
Simple String with an even simpler ``inline literal``
""",
"""\
{'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'''}
"""
],
["""\
A simple `anonymous reference`__
__ http://www.test.com/test_url
""",
"""\
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n'''}
"""],
["""\
One paragraph.
Two paragraphs.
""",
"""\
{'fragment': '''<p>One paragraph.</p>
<p>Two paragraphs.</p>\\n'''}
"""],
["""\
A simple `named reference`_ with stuff in between the
reference and the target.
.. _`named reference`: http://www.test.com/test_url
""",
"""\
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
reference and the target.</p>\\n'''}
"""],
["""\
+++++
Title
+++++
Subtitle
========
Some stuff
Section
-------
Some more stuff
Another Section
...............
And even more stuff
""",
"""\
{'fragment': '''<p>Some stuff</p>
<div class="section" id="section">
<h1><a name="section">Section</a></h1>
<p>Some more stuff</p>
<div class="section" id="another-section">
<h2><a name="another-section">Another Section</a></h2>
<p>And even more stuff</p>
</div>
</div>\\n''',
'subtitle': '''Subtitle''',
'title': '''Title'''}
"""],
["""\
+++++
Title
+++++
:author: me
Some stuff
""",
"""\
{'docinfo': '''<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>me</td></tr>
</tbody>
</table>\\n''',
'fragment': '''<p>Some stuff</p>\\n''',
'meta': '''<meta name="author" content="me" />\\n''',
'title': '''Title'''}
"""]
])
totest['No title promotion'] = ({'doctitle_xform' : 0}, [
["""\
Simple String
""",
"""\
{'fragment': '''<p>Simple String</p>\\n'''}
"""
],
["""\
Simple String with *markup*
""",
"""\
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n'''}
"""
],
["""\
Simple String with an even simpler ``inline literal``
""",
"""\
{'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'''}
"""
],
["""\
A simple `anonymous reference`__
__ http://www.test.com/test_url
""",
"""\
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n'''}
"""],
["""\
A simple `named reference`_ with stuff in between the
reference and the target.
.. _`named reference`: http://www.test.com/test_url
""",
"""\
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
reference and the target.</p>\\n'''}
"""],
["""\
+++++
Title
+++++
Not A Subtitle
==============
Some stuff
Section
-------
Some more stuff
Another Section
...............
And even more stuff
""",
"""\
{'fragment': '''<div class="section" id="title">
<h1><a name="title">Title</a></h1>
<div class="section" id="not-a-subtitle">
<h2><a name="not-a-subtitle">Not A Subtitle</a></h2>
<p>Some stuff</p>
<div class="section" id="section">
<h3><a name="section">Section</a></h3>
<p>Some more stuff</p>
<div class="section" id="another-section">
<h4><a name="another-section">Another Section</a></h4>
<p>And even more stuff</p>
</div>
</div>
</div>
</div>\\n'''}
"""]
])
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')
|