~ubuntu-branches/ubuntu/karmic/python-docutils/karmic

« back to all changes in this revision

Viewing changes to test/test_rst/test_directives/test_figures.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
 
"""
4
 
:Author: David Goodger
5
 
:Contact: goodger@users.sourceforge.net
6
 
:Revision: $Revision: 1.3 $
7
 
:Date: $Date: 2002/05/05 15:48:30 $
8
 
:Copyright: This module has been placed in the public domain.
9
 
 
10
 
Tests for images.py figure directives.
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['figures'] = [
23
 
["""\
24
 
.. figure:: picture.png
25
 
""",
26
 
"""\
27
 
<document>
28
 
    <figure>
29
 
        <image uri="picture.png">
30
 
"""],
31
 
["""\
32
 
.. figure:: not an image URI
33
 
""",
34
 
"""\
35
 
<document>
36
 
    <system_message level="3" type="ERROR">
37
 
        <paragraph>
38
 
            Image URI at line 1 contains whitespace.
39
 
        <literal_block>
40
 
            .. figure:: not an image URI
41
 
"""],
42
 
["""\
43
 
.. figure:: picture.png
44
 
 
45
 
   A picture with a caption.
46
 
""",
47
 
"""\
48
 
<document>
49
 
    <figure>
50
 
        <image uri="picture.png">
51
 
        <caption>
52
 
            A picture with a caption.
53
 
"""],
54
 
["""\
55
 
.. figure:: picture.png
56
 
 
57
 
   - A picture with an invalid caption.
58
 
""",
59
 
"""\
60
 
<document>
61
 
    <figure>
62
 
        <image uri="picture.png">
63
 
    <system_message level="3" type="ERROR">
64
 
        <paragraph>
65
 
            Figure caption must be a paragraph or empty comment.
66
 
        <literal_block>
67
 
            .. figure:: picture.png
68
 
            \n\
69
 
               - A picture with an invalid caption.
70
 
"""],
71
 
["""\
72
 
.. figure:: not an image URI
73
 
 
74
 
   And a caption.
75
 
""",
76
 
"""\
77
 
<document>
78
 
    <system_message level="3" type="ERROR">
79
 
        <paragraph>
80
 
            Image URI at line 1 contains whitespace.
81
 
        <literal_block>
82
 
            .. figure:: not an image URI
83
 
            \n\
84
 
               And a caption.
85
 
"""],
86
 
["""\
87
 
.. figure:: picture.png
88
 
 
89
 
   ..
90
 
 
91
 
   A picture with a legend but no caption.
92
 
""",
93
 
"""\
94
 
<document>
95
 
    <figure>
96
 
        <image uri="picture.png">
97
 
        <legend>
98
 
            <paragraph>
99
 
                A picture with a legend but no caption.
100
 
"""],
101
 
["""\
102
 
.. Figure:: picture.png
103
 
   :height: 100
104
 
   :width: 200
105
 
   :scale: 50
106
 
 
107
 
   A picture with image attributes and a caption.
108
 
""",
109
 
"""\
110
 
<document>
111
 
    <figure>
112
 
        <image height="100" scale="50" uri="picture.png" width="200">
113
 
        <caption>
114
 
            A picture with image attributes and a caption.
115
 
"""],
116
 
["""\
117
 
.. Figure:: picture.png
118
 
   :height: 100
119
 
   :alt: alternate text
120
 
   :width: 200
121
 
   :scale: 50
122
 
 
123
 
   A picture with image attributes on individual lines, and this caption.
124
 
""",
125
 
"""\
126
 
<document>
127
 
    <figure>
128
 
        <image alt="alternate text" height="100" scale="50" uri="picture.png" width="200">
129
 
        <caption>
130
 
            A picture with image attributes on individual lines, and this caption.
131
 
"""],
132
 
["""\
133
 
This figure lacks a caption. It may still have a
134
 
"Figure 1."-style caption appended in the output.
135
 
 
136
 
.. figure:: picture.png
137
 
""",
138
 
"""\
139
 
<document>
140
 
    <paragraph>
141
 
        This figure lacks a caption. It may still have a
142
 
        "Figure 1."-style caption appended in the output.
143
 
    <figure>
144
 
        <image uri="picture.png">
145
 
"""],
146
 
["""\
147
 
.. figure:: picture.png
148
 
 
149
 
   A picture with a caption and a legend.
150
 
 
151
 
   +-----------------------+-----------------------+
152
 
   | Symbol                | Meaning               |
153
 
   +=======================+=======================+
154
 
   | .. image:: tent.png   | Campground            |
155
 
   +-----------------------+-----------------------+
156
 
   | .. image:: waves.png  | Lake                  |
157
 
   +-----------------------+-----------------------+
158
 
   | .. image:: peak.png   | Mountain              |
159
 
   +-----------------------+-----------------------+
160
 
""",
161
 
"""\
162
 
<document>
163
 
    <figure>
164
 
        <image uri="picture.png">
165
 
        <caption>
166
 
            A picture with a caption and a legend.
167
 
        <legend>
168
 
            <table>
169
 
                <tgroup cols="2">
170
 
                    <colspec colwidth="23">
171
 
                    <colspec colwidth="23">
172
 
                    <thead>
173
 
                        <row>
174
 
                            <entry>
175
 
                                <paragraph>
176
 
                                    Symbol
177
 
                            <entry>
178
 
                                <paragraph>
179
 
                                    Meaning
180
 
                    <tbody>
181
 
                        <row>
182
 
                            <entry>
183
 
                                <image uri="tent.png">
184
 
                            <entry>
185
 
                                <paragraph>
186
 
                                    Campground
187
 
                        <row>
188
 
                            <entry>
189
 
                                <image uri="waves.png">
190
 
                            <entry>
191
 
                                <paragraph>
192
 
                                    Lake
193
 
                        <row>
194
 
                            <entry>
195
 
                                <image uri="peak.png">
196
 
                            <entry>
197
 
                                <paragraph>
198
 
                                    Mountain
199
 
"""],
200
 
["""\
201
 
.. figure:: picture.png
202
 
 
203
 
   ..
204
 
 
205
 
   A picture with a legend but no caption.
206
 
   (The empty comment replaces the caption, which must
207
 
   be a single paragraph.)
208
 
""",
209
 
"""\
210
 
<document>
211
 
    <figure>
212
 
        <image uri="picture.png">
213
 
        <legend>
214
 
            <paragraph>
215
 
                A picture with a legend but no caption.
216
 
                (The empty comment replaces the caption, which must
217
 
                be a single paragraph.)
218
 
"""],
219
 
["""\
220
 
Testing for line-leaks:
221
 
 
222
 
.. figure:: picture.png
223
 
 
224
 
   A picture with a caption.
225
 
.. figure:: picture.png
226
 
 
227
 
   A picture with a caption.
228
 
.. figure:: picture.png
229
 
 
230
 
   A picture with a caption.
231
 
.. figure:: picture.png
232
 
.. figure:: picture.png
233
 
.. figure:: picture.png
234
 
.. figure:: picture.png
235
 
 
236
 
   A picture with a caption.
237
 
 
238
 
.. figure:: picture.png
239
 
 
240
 
.. figure:: picture.png
241
 
 
242
 
   A picture with a caption.
243
 
 
244
 
.. figure:: picture.png
245
 
""",
246
 
"""\
247
 
<document>
248
 
    <paragraph>
249
 
        Testing for line-leaks:
250
 
    <figure>
251
 
        <image uri="picture.png">
252
 
        <caption>
253
 
            A picture with a caption.
254
 
    <figure>
255
 
        <image uri="picture.png">
256
 
        <caption>
257
 
            A picture with a caption.
258
 
    <figure>
259
 
        <image uri="picture.png">
260
 
        <caption>
261
 
            A picture with a caption.
262
 
    <figure>
263
 
        <image uri="picture.png">
264
 
    <figure>
265
 
        <image uri="picture.png">
266
 
    <figure>
267
 
        <image uri="picture.png">
268
 
    <figure>
269
 
        <image uri="picture.png">
270
 
        <caption>
271
 
            A picture with a caption.
272
 
    <figure>
273
 
        <image uri="picture.png">
274
 
    <figure>
275
 
        <image uri="picture.png">
276
 
        <caption>
277
 
            A picture with a caption.
278
 
    <figure>
279
 
        <image uri="picture.png">
280
 
"""],
281
 
]
282
 
 
283
 
 
284
 
if __name__ == '__main__':
285
 
    import unittest
286
 
    unittest.main(defaultTest='suite')