Use `field_marker` pattern to look for start of a directive option block
[docutils.git] / test / test_parsers / test_rst / test_directives / test_admonitions.py
blob09d16d1c930b7bc0398ba172e9c2ae95c5e9549c
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:: Content before options
115 is possible too.
116 :class: mynote
118 .. note:: :strong:`a role is not an option`.
119 :name: role not option
121 .. note:: a role is
122 :strong:`not an option`, even if its starts a line.
123 """,
124 """\
125 <document source="test data">
126 <note classes="mynote">
127 <paragraph>
128 Content before options
129 is possible too.
130 <note ids="role-not-option" names="role\ not\ option">
131 <paragraph>
132 <strong>
133 a role is not an option
135 <note>
136 <paragraph>
137 a role is
138 <strong>
139 not an option
140 , even if its starts a line.
141 """],
142 ["""\
143 .. note::
144 """,
145 """\
146 <document source="test data">
147 <system_message level="3" line="1" source="test data" type="ERROR">
148 <paragraph>
149 Content block expected for the "note" directive; none found.
150 <literal_block xml:space="preserve">
151 .. note::
152 """],
153 ["""\
154 .. admonition:: Admonition
156 This is a generic admonition.
157 """,
158 """\
159 <document source="test data">
160 <admonition classes="admonition-admonition">
161 <title>
162 Admonition
163 <paragraph>
164 This is a generic admonition.
165 """],
166 ["""\
167 .. admonition:: And, by the way...
169 You can make up your own admonition too.
170 """,
171 """\
172 <document source="test data">
173 <admonition classes="admonition-and-by-the-way">
174 <title>
175 And, by the way...
176 <paragraph>
177 You can make up your own admonition too.
178 """],
179 ["""\
180 .. admonition:: Admonition
181 :class: emergency
182 :name: reference name
184 Test the "class" override.
185 """,
186 """\
187 <document source="test data">
188 <admonition classes="emergency" ids="reference-name" names="reference\ name">
189 <title>
190 Admonition
191 <paragraph>
192 Test the "class" override.
193 """],
194 ["""\
195 .. admonition::
197 Generic admonitions require a title.
198 """,
199 """\
200 <document source="test data">
201 <system_message level="3" line="1" source="test data" type="ERROR">
202 <paragraph>
203 Error in "admonition" directive:
204 1 argument(s) required, 0 supplied.
205 <literal_block xml:space="preserve">
206 .. admonition::
208 Generic admonitions require a title.
209 """],
213 if __name__ == '__main__':
214 import unittest
215 unittest.main(defaultTest='suite')