~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to test/test_rst/test_directives/test_images.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/06/28 04:20:46 $
8
 
:Copyright: This module has been placed in the public domain.
9
 
 
10
 
Tests for images.py image 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['images'] = [
23
 
["""\
24
 
.. image:: picture.png
25
 
""",
26
 
"""\
27
 
<document>
28
 
    <image uri="picture.png">
29
 
"""],
30
 
["""\
31
 
.. image::
32
 
""",
33
 
"""\
34
 
<document>
35
 
    <system_message level="3" type="ERROR">
36
 
        <paragraph>
37
 
            Missing image URI argument at line 1.
38
 
        <literal_block>
39
 
            .. image::
40
 
"""],
41
 
["""\
42
 
.. image:: one two three
43
 
""",
44
 
"""\
45
 
<document>
46
 
    <system_message level="3" type="ERROR">
47
 
        <paragraph>
48
 
            Image URI at line 1 contains whitespace.
49
 
        <literal_block>
50
 
            .. image:: one two three
51
 
"""],
52
 
["""\
53
 
.. image:: picture.png
54
 
   :height: 100
55
 
   :width: 200
56
 
   :scale: 50
57
 
""",
58
 
"""\
59
 
<document>
60
 
    <image height="100" scale="50" uri="picture.png" width="200">
61
 
"""],
62
 
["""\
63
 
.. image::
64
 
   picture.png
65
 
   :height: 100
66
 
   :width: 200
67
 
   :scale: 50
68
 
""",
69
 
"""\
70
 
<document>
71
 
    <image height="100" scale="50" uri="picture.png" width="200">
72
 
"""],
73
 
["""\
74
 
.. image::
75
 
   :height: 100
76
 
   :width: 200
77
 
   :scale: 50
78
 
""",
79
 
"""\
80
 
<document>
81
 
    <system_message level="3" type="ERROR">
82
 
        <paragraph>
83
 
            Missing image URI argument at line 1.
84
 
        <literal_block>
85
 
            .. image::
86
 
               :height: 100
87
 
               :width: 200
88
 
               :scale: 50
89
 
"""],
90
 
["""\
91
 
.. image:: a/very/long/path/to/
92
 
   picture.png
93
 
   :height: 100
94
 
   :width: 200
95
 
   :scale: 50
96
 
""",
97
 
"""\
98
 
<document>
99
 
    <image height="100" scale="50" uri="a/very/long/path/to/picture.png" width="200">
100
 
"""],
101
 
["""\
102
 
.. image:: picture.png
103
 
   :height: 100
104
 
   :width: 200
105
 
   :scale: 50
106
 
   :alt: Alternate text for the picture
107
 
""",
108
 
"""\
109
 
<document>
110
 
    <image alt="Alternate text for the picture" height="100" scale="50" uri="picture.png" width="200">
111
 
"""],
112
 
["""\
113
 
.. image:: picture.png
114
 
   :scale: - 50
115
 
""",
116
 
"""\
117
 
<document>
118
 
    <system_message level="3" type="ERROR">
119
 
        <paragraph>
120
 
            Error in "image" directive attributes at line 1:
121
 
            invalid attribute data: extension attribute field body may contain
122
 
            a single paragraph only (attribute "scale").
123
 
        <literal_block>
124
 
            .. image:: picture.png
125
 
               :scale: - 50
126
 
"""],
127
 
["""\
128
 
.. image:: picture.png
129
 
   :scale:
130
 
""",
131
 
"""\
132
 
<document>
133
 
    <system_message level="3" type="ERROR">
134
 
        <paragraph>
135
 
            Error in "image" directive attributes at line 1:
136
 
            invalid attribute value:
137
 
            (attribute "scale", value "None") object can't be converted to int.
138
 
        <literal_block>
139
 
            .. image:: picture.png
140
 
               :scale:
141
 
"""],
142
 
["""\
143
 
.. image:: picture.png
144
 
   :scale 50
145
 
""",
146
 
"""\
147
 
<document>
148
 
    <system_message level="3" type="ERROR">
149
 
        <paragraph>
150
 
            Error in "image" directive attributes at line 1:
151
 
            invalid attribute block.
152
 
        <literal_block>
153
 
            .. image:: picture.png
154
 
               :scale 50
155
 
"""],
156
 
["""\
157
 
.. image:: picture.png
158
 
   scale: 50
159
 
""",
160
 
"""\
161
 
<document>
162
 
    <system_message level="3" type="ERROR">
163
 
        <paragraph>
164
 
            Image URI at line 1 contains whitespace.
165
 
        <literal_block>
166
 
            .. image:: picture.png
167
 
               scale: 50
168
 
"""],
169
 
["""\
170
 
.. image:: picture.png
171
 
   :: 50
172
 
""",
173
 
"""\
174
 
<document>
175
 
    <system_message level="3" type="ERROR">
176
 
        <paragraph>
177
 
            Error in "image" directive attributes at line 1:
178
 
            invalid attribute block.
179
 
        <literal_block>
180
 
            .. image:: picture.png
181
 
               :: 50
182
 
"""],
183
 
["""\
184
 
.. image:: picture.png
185
 
   :sale: 50
186
 
""",
187
 
"""\
188
 
<document>
189
 
    <system_message level="3" type="ERROR">
190
 
        <paragraph>
191
 
            Error in "image" directive attributes at line 1:
192
 
            unknown attribute: "sale".
193
 
        <literal_block>
194
 
            .. image:: picture.png
195
 
               :sale: 50
196
 
"""],
197
 
["""\
198
 
.. image:: picture.png
199
 
   :scale: fifty
200
 
""",
201
 
"""\
202
 
<document>
203
 
    <system_message level="3" type="ERROR">
204
 
        <paragraph>
205
 
            Error in "image" directive attributes at line 1:
206
 
            invalid attribute value:
207
 
            (attribute "scale", value "fifty") invalid literal for int(): fifty.
208
 
        <literal_block>
209
 
            .. image:: picture.png
210
 
               :scale: fifty
211
 
"""],
212
 
["""\
213
 
.. image:: picture.png
214
 
   :scale: 50
215
 
   :scale: 50
216
 
""",
217
 
"""\
218
 
<document>
219
 
    <system_message level="3" type="ERROR">
220
 
        <paragraph>
221
 
            Error in "image" directive attributes at line 1:
222
 
            invalid attribute data: duplicate attribute "scale".
223
 
        <literal_block>
224
 
            .. image:: picture.png
225
 
               :scale: 50
226
 
               :scale: 50
227
 
"""],
228
 
]
229
 
 
230
 
 
231
 
if __name__ == '__main__':
232
 
    import unittest
233
 
    unittest.main(defaultTest='suite')