Common directive options:
[docutils/kirr.git] / docutils / test / test_parsers / test_rst / test_directives / test_admonitions.py
blobc4a01800d97764a8dfdb70caa92bef4af4c1fbe0
1 #! /usr/bin/env python
3 # $Id$
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for admonitions.py directives.
9 """
11 from __init__ import DocutilsTestSupport
13 def suite():
14 s = DocutilsTestSupport.ParserTestSuite()
15 s.generateTests(totest)
16 return s
18 totest = {}
20 totest['admonitions'] = [
21 ["""\
22 .. Attention:: Directives at large.
24 .. Note:: :name: mynote
25 :class: testnote
27 Admonitions support the generic "name" and "class" options.
29 .. Tip:: 15% if the
30 service is good.
32 .. Hint:: It's bigger than a bread box.
34 - .. WARNING:: Strong prose may provoke extreme mental exertion.
35 Reader discretion is strongly advised.
36 - .. Error:: Does not compute.
38 .. Caution::
40 Don't take any wooden nickels.
42 .. DANGER:: Mad scientist at work!
44 .. Important::
45 - Wash behind your ears.
46 - Clean up your room.
47 - Call your mother.
48 - Back up your data.
49 """,
50 """\
51 <document source="test data">
52 <attention>
53 <paragraph>
54 Directives at large.
55 <note classes="testnote" ids="mynote" names="mynote">
56 <paragraph>
57 Admonitions support the generic "name" and "class" options.
58 <tip>
59 <paragraph>
60 15% if the
61 service is good.
62 <hint>
63 <paragraph>
64 It's bigger than a bread box.
65 <bullet_list bullet="-">
66 <list_item>
67 <warning>
68 <paragraph>
69 Strong prose may provoke extreme mental exertion.
70 Reader discretion is strongly advised.
71 <list_item>
72 <error>
73 <paragraph>
74 Does not compute.
75 <caution>
76 <paragraph>
77 Don't take any wooden nickels.
78 <danger>
79 <paragraph>
80 Mad scientist at work!
81 <important>
82 <bullet_list bullet="-">
83 <list_item>
84 <paragraph>
85 Wash behind your ears.
86 <list_item>
87 <paragraph>
88 Clean up your room.
89 <list_item>
90 <paragraph>
91 Call your mother.
92 <list_item>
93 <paragraph>
94 Back up your data.
95 """],
96 ["""\
97 .. note:: One-line notes.
98 .. note:: One after the other.
99 .. note:: No blank lines in-between.
100 """,
101 """\
102 <document source="test data">
103 <note>
104 <paragraph>
105 One-line notes.
106 <note>
107 <paragraph>
108 One after the other.
109 <note>
110 <paragraph>
111 No blank lines in-between.
112 """],
113 ["""\
114 .. note::
115 """,
116 """\
117 <document source="test data">
118 <system_message level="3" line="1" source="test data" type="ERROR">
119 <paragraph>
120 Content block expected for the "note" directive; none found.
121 <literal_block xml:space="preserve">
122 .. note::
123 """],
124 ["""\
125 .. admonition:: Admonition
127 This is a generic admonition.
128 """,
129 """\
130 <document source="test data">
131 <admonition classes="admonition-admonition">
132 <title>
133 Admonition
134 <paragraph>
135 This is a generic admonition.
136 """],
137 ["""\
138 .. admonition:: And, by the way...
140 You can make up your own admonition too.
141 """,
142 """\
143 <document source="test data">
144 <admonition classes="admonition-and-by-the-way">
145 <title>
146 And, by the way...
147 <paragraph>
148 You can make up your own admonition too.
149 """],
150 ["""\
151 .. admonition:: Admonition
152 :class: emergency
153 :name: reference name
155 Test the "class" override.
156 """,
157 """\
158 <document source="test data">
159 <admonition classes="emergency" ids="reference-name" names="reference\ name">
160 <title>
161 Admonition
162 <paragraph>
163 Test the "class" override.
164 """],
165 ["""\
166 .. admonition::
168 Generic admonitions require a title.
169 """,
170 """\
171 <document source="test data">
172 <system_message level="3" line="1" source="test data" type="ERROR">
173 <paragraph>
174 Error in "admonition" directive:
175 1 argument(s) required, 0 supplied.
176 <literal_block xml:space="preserve">
177 .. admonition::
179 Generic admonitions require a title.
180 """],
184 if __name__ == '__main__':
185 import unittest
186 unittest.main(defaultTest='suite')