~ubuntu-branches/ubuntu/hardy/python-docutils/hardy

« back to all changes in this revision

Viewing changes to test/test_parsers/test_rst/test_line_blocks.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
# Author: David Goodger
 
4
# Contact: goodger@python.org
 
5
# Revision: $Revision: 3129 $
 
6
# Date: $Date: 2005-03-26 17:21:28 +0100 (Sat, 26 Mar 2005) $
 
7
# Copyright: This module has been placed in the public domain.
 
8
 
 
9
"""
 
10
Tests for states.py.
 
11
"""
 
12
 
 
13
from __init__ import DocutilsTestSupport
 
14
 
 
15
def suite():
 
16
    s = DocutilsTestSupport.ParserTestSuite()
 
17
    s.generateTests(totest)
 
18
    return s
 
19
 
 
20
totest = {}
 
21
 
 
22
totest['line_blocks'] = [
 
23
["""\
 
24
| This is a line block.
 
25
| Line breaks are *preserved*.
 
26
 
 
27
| This is a second line block.
 
28
 
 
29
| This is a third.
 
30
""",
 
31
"""\
 
32
<document source="test data">
 
33
    <line_block>
 
34
        <line>
 
35
            This is a line block.
 
36
        <line>
 
37
            Line breaks are \n\
 
38
            <emphasis>
 
39
                preserved
 
40
            .
 
41
    <line_block>
 
42
        <line>
 
43
            This is a second line block.
 
44
    <line_block>
 
45
        <line>
 
46
            This is a third.
 
47
"""],
 
48
["""\
 
49
| In line blocks,
 
50
|     Initial indentation is *also* preserved.
 
51
""",
 
52
"""\
 
53
<document source="test data">
 
54
    <line_block>
 
55
        <line>
 
56
            In line blocks,
 
57
        <line_block>
 
58
            <line>
 
59
                Initial indentation is \n\
 
60
                <emphasis>
 
61
                    also
 
62
                 preserved.
 
63
"""],
 
64
["""\
 
65
| Individual lines in line blocks
 
66
  *may* wrap, as indicated by the lack of a vertical bar prefix.
 
67
| These are called "continuation lines".
 
68
""",
 
69
"""\
 
70
<document source="test data">
 
71
    <line_block>
 
72
        <line>
 
73
            Individual lines in line blocks
 
74
            <emphasis>
 
75
                may
 
76
             wrap, as indicated by the lack of a vertical bar prefix.
 
77
        <line>
 
78
            These are called "continuation lines".
 
79
"""],
 
80
["""\
 
81
| Inline markup in line blocks may also wrap *to
 
82
  continuation lines*.
 
83
| But not to following lines.
 
84
""",
 
85
"""\
 
86
<document source="test data">
 
87
    <line_block>
 
88
        <line>
 
89
            Inline markup in line blocks may also wrap \n\
 
90
            <emphasis>
 
91
                to
 
92
                continuation lines
 
93
            .
 
94
        <line>
 
95
            But not to following lines.
 
96
"""],
 
97
["""\
 
98
\\| This is not a line block.
 
99
The vertical bar is simply part of a paragraph.
 
100
""",
 
101
"""\
 
102
<document source="test data">
 
103
    <paragraph>
 
104
        | This is not a line block.
 
105
        The vertical bar is simply part of a paragraph.
 
106
"""],
 
107
["""\
 
108
| This line block is incomplete.
 
109
There should be a blank line before this paragraph.
 
110
""",
 
111
"""\
 
112
<document source="test data">
 
113
    <line_block>
 
114
        <line>
 
115
            This line block is incomplete.
 
116
    <system_message level="2" line="2" source="test data" type="WARNING">
 
117
        <paragraph>
 
118
            Line block ends without a blank line.
 
119
    <paragraph>
 
120
        There should be a blank line before this paragraph.
 
121
"""],
 
122
["""\
 
123
| This line block contains
 
124
|
 
125
| blank lines.
 
126
""",
 
127
"""\
 
128
<document source="test data">
 
129
    <line_block>
 
130
        <line>
 
131
            This line block contains
 
132
        <line>
 
133
        <line>
 
134
            blank lines.
 
135
"""],
 
136
["""\
 
137
| The blank lines in this block
 
138
|   \n\
 
139
|       \n\
 
140
| have bogus spaces.
 
141
""",
 
142
"""\
 
143
<document source="test data">
 
144
    <line_block>
 
145
        <line>
 
146
            The blank lines in this block
 
147
        <line>
 
148
        <line>
 
149
        <line>
 
150
            have bogus spaces.
 
151
"""],
 
152
["""\
 
153
| Initial indentation is also significant and preserved:
 
154
|
 
155
|     Indented 4 spaces
 
156
| Not indented
 
157
|   Indented 2 spaces
 
158
|     Indented 4 spaces
 
159
|  Only one space
 
160
|
 
161
|     Continuation lines may be indented less
 
162
  than their base lines.
 
163
""",
 
164
"""\
 
165
<document source="test data">
 
166
    <line_block>
 
167
        <line>
 
168
            Initial indentation is also significant and preserved:
 
169
        <line>
 
170
        <line_block>
 
171
            <line>
 
172
                Indented 4 spaces
 
173
        <line>
 
174
            Not indented
 
175
        <line_block>
 
176
            <line_block>
 
177
                <line>
 
178
                    Indented 2 spaces
 
179
                <line_block>
 
180
                    <line>
 
181
                        Indented 4 spaces
 
182
            <line>
 
183
                Only one space
 
184
            <line>
 
185
            <line_block>
 
186
                <line>
 
187
                    Continuation lines may be indented less
 
188
                    than their base lines.
 
189
"""],
 
190
["""\
 
191
|
 
192
| This block begins and ends with blank lines.
 
193
|
 
194
""",
 
195
"""\
 
196
<document source="test data">
 
197
    <line_block>
 
198
        <line>
 
199
        <line>
 
200
            This block begins and ends with blank lines.
 
201
        <line>
 
202
"""],
 
203
["""\
 
204
This is not
 
205
| a line block.
 
206
""",
 
207
"""\
 
208
<document source="test data">
 
209
    <paragraph>
 
210
        This is not
 
211
        | a line block.
 
212
"""],
 
213
["""\
 
214
|   The first line is indented.
 
215
|     The second line is more indented.
 
216
""",
 
217
"""\
 
218
<document source="test data">
 
219
    <line_block>
 
220
        <line>
 
221
            The first line is indented.
 
222
        <line_block>
 
223
            <line>
 
224
                The second line is more indented.
 
225
"""],
 
226
["""\
 
227
|     The first line is indented.
 
228
|   The second line is less indented.
 
229
""",
 
230
"""\
 
231
<document source="test data">
 
232
    <line_block>
 
233
        <line_block>
 
234
            <line>
 
235
                The first line is indented.
 
236
        <line>
 
237
            The second line is less indented.
 
238
"""],
 
239
["""\
 
240
|This is not
 
241
|a line block
 
242
 
 
243
| This is an
 
244
|incomplete line block.
 
245
""",
 
246
"""\
 
247
<document source="test data">
 
248
    <paragraph>
 
249
        <problematic ids="id2" refid="id1">
 
250
            |
 
251
        This is not
 
252
        <problematic ids="id4" refid="id3">
 
253
            |
 
254
        a line block
 
255
    <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
 
256
        <paragraph>
 
257
            Inline substitution_reference start-string without end-string.
 
258
    <system_message backrefs="id4" ids="id3" level="2" line="1" source="test data" type="WARNING">
 
259
        <paragraph>
 
260
            Inline substitution_reference start-string without end-string.
 
261
    <line_block>
 
262
        <line>
 
263
            This is an
 
264
    <system_message level="2" line="5" source="test data" type="WARNING">
 
265
        <paragraph>
 
266
            Line block ends without a blank line.
 
267
    <paragraph>
 
268
        <problematic ids="id6" refid="id5">
 
269
            |
 
270
        incomplete line block.
 
271
    <system_message backrefs="id6" ids="id5" level="2" line="5" source="test data" type="WARNING">
 
272
        <paragraph>
 
273
            Inline substitution_reference start-string without end-string.
 
274
"""],
 
275
["""\
 
276
| Inline markup *may not
 
277
| wrap* over several lines.
 
278
""",
 
279
"""\
 
280
<document source="test data">
 
281
    <line_block>
 
282
        <line>
 
283
            Inline markup \n\
 
284
            <problematic ids="id2" refid="id1">
 
285
                *
 
286
            may not
 
287
        <line>
 
288
            wrap* over several lines.
 
289
    <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
 
290
        <paragraph>
 
291
            Inline emphasis start-string without end-string.
 
292
"""],
 
293
["""\
 
294
| * Block level markup
 
295
| * is not recognized.
 
296
""",
 
297
"""\
 
298
<document source="test data">
 
299
    <line_block>
 
300
        <line>
 
301
            * Block level markup
 
302
        <line>
 
303
            * is not recognized.
 
304
"""],
 
305
]
 
306
 
 
307
 
 
308
if __name__ == '__main__':
 
309
    import unittest
 
310
    unittest.main(defaultTest='suite')