4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
11 from __init__
import DocutilsTestSupport
14 s
= DocutilsTestSupport
.ParserTestSuite()
15 s
.generateTests(totest
)
20 totest
['substitution_definitions'] = [
22 Here's an image substitution definition:
24 .. |symbol| image:: symbol.png
27 <document source="test data">
29 Here's an image substitution definition:
30 <substitution_definition names="symbol">
31 <image alt="symbol" uri="symbol.png">
34 Embedded directive starts on the next line:
40 <document source="test data">
42 Embedded directive starts on the next line:
43 <substitution_definition names="symbol">
44 <image alt="symbol" uri="symbol.png">
47 Trailing spaces should not be significant:
49 .. |symbol| image:: \n\
53 <document source="test data">
55 Trailing spaces should not be significant:
56 <substitution_definition names="symbol">
57 <image alt="symbol" uri="symbol.png">
60 Here's a series of substitution definitions:
62 .. |symbol 1| image:: symbol1.png
63 .. |SYMBOL 2| image:: symbol2.png
66 .. |symbol 3| image:: symbol3.png
69 <document source="test data">
71 Here's a series of substitution definitions:
72 <substitution_definition names="symbol\ 1">
73 <image alt="symbol 1" uri="symbol1.png">
74 <substitution_definition names="SYMBOL\ 2">
75 <image alt="SYMBOL 2" height="50" uri="symbol2.png" width="100">
76 <substitution_definition names="symbol\ 3">
77 <image alt="symbol 3" uri="symbol3.png">
80 .. |very long substitution text,
81 split across lines| image:: symbol.png
84 <document source="test data">
85 <substitution_definition names="very\ long\ substitution\ text,\ split\ across\ lines">
86 <image alt="very long substitution text, split across lines" uri="symbol.png">
89 .. |symbol 1| image:: symbol.png
91 Followed by a block quote.
94 <document source="test data">
95 <system_message level="3" line="1" source="test data" type="ERROR">
97 Error in "image" directive:
99 <literal_block xml:space="preserve">
102 Followed by a block quote.
103 <system_message level="2" line="1" source="test data" type="WARNING">
105 Substitution definition "symbol 1" empty or invalid.
106 <literal_block xml:space="preserve">
107 .. |symbol 1| image:: symbol.png
109 Followed by a block quote.
112 .. |symbol 1| image:: symbol.png
114 Followed by a paragraph.
116 .. |symbol 2| image:: symbol.png
120 Followed by a block quote.
123 <document source="test data">
124 <substitution_definition names="symbol\ 1">
125 <image alt="symbol 1" uri="symbol.png">
127 Followed by a paragraph.
128 <substitution_definition names="symbol\ 2">
129 <image alt="symbol 2" uri="symbol.png">
130 <comment xml:space="preserve">
133 Followed by a block quote.
136 Substitutions support case differences:
138 .. |eacute| replace:: \u00E9
139 .. |Eacute| replace:: \u00C9
142 <document source="test data">
144 Substitutions support case differences:
145 <substitution_definition names="eacute">
147 <substitution_definition names="Eacute">
151 Raw substitution, backslashes should be preserved:
153 .. |alpha| raw:: latex
158 <document source="test data">
160 Raw substitution, backslashes should be preserved:
161 <substitution_definition names="alpha">
162 <raw format="latex" xml:space="preserve">
166 Here are some duplicate substitution definitions:
168 .. |symbol| image:: symbol.png
169 .. |symbol| image:: symbol.png
172 <document source="test data">
174 Here are some duplicate substitution definitions:
175 <substitution_definition dupnames="symbol">
176 <image alt="symbol" uri="symbol.png">
177 <system_message level="3" line="4" source="test data" type="ERROR">
179 Duplicate substitution definition name: "symbol".
180 <substitution_definition names="symbol">
181 <image alt="symbol" uri="symbol.png">
184 Here are some bad cases:
186 .. |symbol| image:: symbol.png
191 .. |unknown| directive:: symbol.png
193 .. |invalid 1| there's no directive here
194 .. |invalid 2| there's no directive here
195 With some block quote text, line 1.
196 And some more, line 2.
198 .. |invalid 3| there's no directive here
200 .. | bad name | bad data
205 <document source="test data">
207 Here are some bad cases:
208 <substitution_definition names="symbol">
209 <image alt="symbol" uri="symbol.png">
210 <system_message level="2" line="4" source="test data" type="WARNING">
212 Explicit markup ends without a blank line; unexpected unindent.
215 <system_message level="2" line="6" source="test data" type="WARNING">
217 Substitution definition "empty" missing contents.
218 <literal_block xml:space="preserve">
220 <system_message level="1" line="8" source="test data" type="INFO">
222 No directive entry for "directive" in module "docutils.parsers.rst.languages.en".
223 Trying "directive" as canonical directive name.
224 <system_message level="3" line="8" source="test data" type="ERROR">
226 Unknown directive type "directive".
227 <literal_block xml:space="preserve">
228 directive:: symbol.png
229 <system_message level="2" line="8" source="test data" type="WARNING">
231 Substitution definition "unknown" empty or invalid.
232 <literal_block xml:space="preserve">
233 .. |unknown| directive:: symbol.png
234 <system_message level="2" line="10" source="test data" type="WARNING">
236 Substitution definition "invalid 1" empty or invalid.
237 <literal_block xml:space="preserve">
238 .. |invalid 1| there's no directive here
239 <system_message level="2" line="11" source="test data" type="WARNING">
241 Substitution definition "invalid 2" empty or invalid.
242 <literal_block xml:space="preserve">
243 .. |invalid 2| there's no directive here
244 With some block quote text, line 1.
245 And some more, line 2.
246 <system_message level="2" line="15" source="test data" type="WARNING">
248 Substitution definition "invalid 3" empty or invalid.
249 <literal_block xml:space="preserve">
250 .. |invalid 3| there's no directive here
251 <comment xml:space="preserve">
252 | bad name | bad data
253 <comment xml:space="preserve">
257 Elements that are prohibited inside of substitution definitions:
259 .. |target| replace:: _`target`
260 .. |reference| replace:: anonymous__
261 .. |auto-numbered footnote| replace:: [#]_
264 <document source="test data">
266 Elements that are prohibited inside of substitution definitions:
267 <system_message level="3" line="3" source="test data" type="ERROR">
269 Substitution definition contains illegal element:
270 <literal_block xml:space="preserve">
271 <target ids="target" names="target">
273 <literal_block xml:space="preserve">
274 .. |target| replace:: _`target`
275 <system_message level="3" line="4" source="test data" type="ERROR">
277 Substitution definition contains illegal element:
278 <literal_block xml:space="preserve">
279 <reference anonymous="1" name="anonymous">
281 <literal_block xml:space="preserve">
282 .. |reference| replace:: anonymous__
283 <system_message level="3" line="5" source="test data" type="ERROR">
285 Substitution definition contains illegal element:
286 <literal_block xml:space="preserve">
287 <footnote_reference auto="1" ids="id1">
288 <literal_block xml:space="preserve">
289 .. |auto-numbered footnote| replace:: [#]_
294 if __name__
== '__main__':
296 unittest
.main(defaultTest
='suite')