4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
8 Tests for interpreted text in docutils/parsers/rst/states.py.
11 from __init__
import DocutilsTestSupport
12 from docutils
.utils
.code_analyzer
import with_pygments
15 s
= DocutilsTestSupport
.ParserTestSuite()
17 del(totest
['code-parsing'])
18 s
.generateTests(totest
)
28 <document source="test data">
37 <document source="test data">
46 <document source="test data">
52 `interpreted \`title``
55 <document source="test data">
61 :title:`:not-role: interpreted`
64 <document source="test data">
67 :not-role: interpreted
70 `interpreted` but not \\`interpreted` [`] or ({[`] or [`]}) or `
73 <document source="test data">
77 but not `interpreted` [`] or ({[`] or [`]}) or `
80 `interpreted`-text `interpreted`: text `interpreted`:text `text`'s interpreted
83 <document source="test data">
99 `interpreted without closing backquote
102 <document source="test data">
104 <problematic ids="id2" refid="id1">
106 interpreted without closing backquote
107 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
109 Inline interpreted text or phrase reference start-string without end-string.
112 `interpreted`:not a role if it contains whitespace:
115 <document source="test data">
119 :not a role if it contains whitespace:
122 :title:`` (empty interpteted text not recognized)
125 <document source="test data">
127 :title:`` (empty interpteted text not recognized)
130 :title:`\ ` (interpteted text containing empty string)
133 <document source="test data">
136 (interpteted text containing empty string)
139 `\ `:title: (interpteted text containing empty string (postfix))
142 <document source="test data">
145 (interpteted text containing empty string (postfix))
151 <document source="test data">
157 :title:`\ ` (trailing unquoted space)
160 <document source="test data">
163 <problematic ids="id2" refid="id1">
165 ` (trailing unquoted space)
166 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
168 Inline interpreted text or phrase reference start-string without end-string.
171 Explicit roles for standard inline markup:
172 :emphasis:`emphasis`,
174 :literal:`inline literal text`.
177 <document source="test data">
179 Explicit roles for standard inline markup:
191 Simple explicit roles:
196 :title:`title reference`.
199 <document source="test data">
201 Simple explicit roles:
222 Code role for inline code snippets:
223 :code:`$\alpha = \int_0^\infty f(x) dx$`.
226 <document source="test data">
228 Code role for inline code snippets:
229 <literal classes="code">
230 $\x07lpha = \\int_0^\\infty f(x) dx$
235 totest
['code-parsing'] = [
240 Custom role based on code role:
241 :tex:`$\alpha = f(x)$`.
244 <document source="test data">
246 Custom role based on code role:
247 <literal classes="code tex latex">
248 <inline classes="literal string">
250 <inline classes="name builtin">
252 <inline classes="operator">
254 <inline classes="name builtin">
256 <inline classes="operator">
258 <inline classes="name builtin">
260 <inline classes="operator">
262 <inline classes="literal string">
267 Custom role based on code role:
269 .. role:: python(code)
273 Python code :python:`print("The end")`.
276 <document source="test data">
278 Custom role based on code role:
281 <literal classes="code testclass python">
282 <inline classes="keyword">
284 <inline classes="punctuation">
286 <inline classes="literal string">
288 <inline classes="punctuation">
294 totest
['references'] = [
299 <document source="test data">
301 <reference refuri="http://www.python.org/dev/peps/pep-0000">
308 <document source="test data">
310 <problematic ids="id2" refid="id1">
312 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
314 PEP number must be a number from 0 to 9999; "-1" is invalid.
320 <document source="test data">
322 <reference refuri="http://www.faqs.org/rfcs/rfc2822.html">
329 <document source="test data">
331 <problematic ids="id2" refid="id1">
333 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
335 RFC number must be a number greater than or equal to 1; "0" is invalid.
339 totest
['unknown_roles'] = [
344 <document source="test data">
346 <problematic ids="id2" refid="id1">
348 <system_message level="1" line="1" source="test data" type="INFO">
350 No role entry for "role" in module "docutils.parsers.rst.languages.en".
351 Trying "role" as canonical role name.
352 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
354 Unknown interpreted text role "role".
360 <document source="test data">
362 <problematic ids="id2" refid="id1">
364 <system_message level="1" line="1" source="test data" type="INFO">
366 No role entry for "role" in module "docutils.parsers.rst.languages.en".
367 Trying "role" as canonical role name.
368 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
370 Unknown interpreted text role "role".
373 :role:`interpreted`:role:
376 <document source="test data">
378 <problematic ids="id2" refid="id1">
379 :role:`interpreted`:role:
380 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
382 Multiple roles in interpreted text (both prefix and suffix present; only one allowed).
385 :very.long-role_name:`interpreted`
388 <document source="test data">
390 <problematic ids="id2" refid="id1">
391 :very.long-role_name:`interpreted`
392 <system_message level="1" line="1" source="test data" type="INFO">
394 No role entry for "very.long-role_name" in module "docutils.parsers.rst.languages.en".
395 Trying "very.long-role_name" as canonical role name.
396 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
398 Unknown interpreted text role "very.long-role_name".
401 :restructuredtext-unimplemented-role:`interpreted`
404 <document source="test data">
406 <problematic ids="id2" refid="id1">
407 :restructuredtext-unimplemented-role:`interpreted`
408 <system_message level="1" line="1" source="test data" type="INFO">
410 No role entry for "restructuredtext-unimplemented-role" in module "docutils.parsers.rst.languages.en".
411 Trying "restructuredtext-unimplemented-role" as canonical role name.
412 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
414 Interpreted text role "restructuredtext-unimplemented-role" not implemented.
419 if __name__
== '__main__':
421 unittest
.main(defaultTest
='suite')