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

« back to all changes in this revision

Viewing changes to test/test_rst/test_substitutions.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/04/25 03:43:53 $
8
 
:Copyright: This module has been placed in the public domain.
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['substitution_definitions'] = [
23
 
["""\
24
 
Here's an image substitution definition:
25
 
 
26
 
.. |symbol| image:: symbol.png
27
 
""",
28
 
"""\
29
 
<document>
30
 
    <paragraph>
31
 
        Here's an image substitution definition:
32
 
    <substitution_definition name="symbol">
33
 
        <image alt="symbol" uri="symbol.png">
34
 
"""],
35
 
["""\
36
 
Embedded directive starts on the next line:
37
 
 
38
 
.. |symbol|
39
 
   image:: symbol.png
40
 
""",
41
 
"""\
42
 
<document>
43
 
    <paragraph>
44
 
        Embedded directive starts on the next line:
45
 
    <substitution_definition name="symbol">
46
 
        <image alt="symbol" uri="symbol.png">
47
 
"""],
48
 
["""\
49
 
Here's a series of substitution definitions:
50
 
 
51
 
.. |symbol 1| image:: symbol1.png
52
 
.. |SYMBOL 2| image:: symbol2.png
53
 
   :height: 50
54
 
   :width: 100
55
 
.. |symbol 3| image:: symbol3.png
56
 
""",
57
 
"""\
58
 
<document>
59
 
    <paragraph>
60
 
        Here's a series of substitution definitions:
61
 
    <substitution_definition name="symbol 1">
62
 
        <image alt="symbol 1" uri="symbol1.png">
63
 
    <substitution_definition name="symbol 2">
64
 
        <image alt="SYMBOL 2" height="50" uri="symbol2.png" width="100">
65
 
    <substitution_definition name="symbol 3">
66
 
        <image alt="symbol 3" uri="symbol3.png">
67
 
"""],
68
 
["""\
69
 
.. |very long substitution text,
70
 
   split across lines| image:: symbol.png
71
 
""",
72
 
"""\
73
 
<document>
74
 
    <substitution_definition name="very long substitution text, split across lines">
75
 
        <image alt="very long substitution text, split across lines" uri="symbol.png">
76
 
"""],
77
 
["""\
78
 
.. |symbol 1| image:: symbol.png
79
 
 
80
 
Followed by a paragraph.
81
 
 
82
 
.. |symbol 2| image:: symbol.png
83
 
 
84
 
    Followed by a block quote.
85
 
""",
86
 
"""\
87
 
<document>
88
 
    <substitution_definition name="symbol 1">
89
 
        <image alt="symbol 1" uri="symbol.png">
90
 
    <paragraph>
91
 
        Followed by a paragraph.
92
 
    <substitution_definition name="symbol 2">
93
 
        <image alt="symbol 2" uri="symbol.png">
94
 
    <block_quote>
95
 
        <paragraph>
96
 
            Followed by a block quote.
97
 
"""],
98
 
["""\
99
 
Here are some duplicate substitution definitions:
100
 
 
101
 
.. |symbol| image:: symbol.png
102
 
.. |symbol| image:: symbol.png
103
 
""",
104
 
"""\
105
 
<document>
106
 
    <paragraph>
107
 
        Here are some duplicate substitution definitions:
108
 
    <substitution_definition dupname="symbol">
109
 
        <image alt="symbol" uri="symbol.png">
110
 
    <system_message level="3" type="ERROR">
111
 
        <paragraph>
112
 
            Duplicate substitution definition name: "symbol".
113
 
    <substitution_definition name="symbol">
114
 
        <image alt="symbol" uri="symbol.png">
115
 
"""],
116
 
["""\
117
 
Here are some bad cases:
118
 
 
119
 
.. |symbol| image:: symbol.png
120
 
No blank line after.
121
 
 
122
 
.. |empty|
123
 
 
124
 
.. |unknown| directive:: symbol.png
125
 
 
126
 
.. |invalid 1| there's no directive here
127
 
.. |invalid 2| there's no directive here
128
 
   With some block quote text, line 1.
129
 
   And some more, line 2.
130
 
 
131
 
.. |invalid 3| there's no directive here
132
 
 
133
 
.. | bad name | bad data
134
 
""",
135
 
"""\
136
 
<document>
137
 
    <paragraph>
138
 
        Here are some bad cases:
139
 
    <substitution_definition name="symbol">
140
 
        <image alt="symbol" uri="symbol.png">
141
 
    <system_message level="2" type="WARNING">
142
 
        <paragraph>
143
 
            Explicit markup ends without a blank line; unexpected unindent at line 4.
144
 
    <paragraph>
145
 
        No blank line after.
146
 
    <system_message level="2" type="WARNING">
147
 
        <paragraph>
148
 
            Substitution definition "empty" missing contents at line 6.
149
 
        <literal_block>
150
 
            .. |empty|
151
 
    <system_message level="3" type="ERROR">
152
 
        <paragraph>
153
 
            Unknown directive type "directive" at line 8.
154
 
        <literal_block>
155
 
            directive:: symbol.png
156
 
    <system_message level="2" type="WARNING">
157
 
        <paragraph>
158
 
            Substitution definition "unknown" empty or invalid at line 8.
159
 
        <literal_block>
160
 
            .. |unknown| directive:: symbol.png
161
 
    <system_message level="2" type="WARNING">
162
 
        <paragraph>
163
 
            Substitution definition "invalid 1" empty or invalid at line 10.
164
 
        <literal_block>
165
 
            .. |invalid 1| there's no directive here
166
 
    <system_message level="2" type="WARNING">
167
 
        <paragraph>
168
 
            Substitution definition "invalid 2" empty or invalid at line 11.
169
 
        <literal_block>
170
 
            .. |invalid 2| there's no directive here
171
 
               With some block quote text, line 1.
172
 
               And some more, line 2.
173
 
    <system_message level="2" type="WARNING">
174
 
        <paragraph>
175
 
            Explicit markup ends without a blank line; unexpected unindent at line 12.
176
 
    <block_quote>
177
 
        <paragraph>
178
 
            With some block quote text, line 1.
179
 
            And some more, line 2.
180
 
    <system_message level="2" type="WARNING">
181
 
        <paragraph>
182
 
            Substitution definition "invalid 3" empty or invalid at line 15.
183
 
        <literal_block>
184
 
            .. |invalid 3| there's no directive here
185
 
    <comment>
186
 
        | bad name | bad data
187
 
"""],
188
 
]
189
 
 
190
 
if __name__ == '__main__':
191
 
    import unittest
192
 
    unittest.main(defaultTest='suite')