Add test for ``.-_`` in citation labels.
[docutils.git] / test / test_parsers / test_rst / test_citations.py
blob349569ba30e2bfd00c2518cf80254dae41234b9b
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 states.py.
9 """
11 from __init__ import DocutilsTestSupport
13 def suite():
14 s = DocutilsTestSupport.ParserTestSuite()
15 s.generateTests(totest)
16 return s
18 totest = {}
20 totest['citations'] = [
21 ["""\
22 .. [citation] This is a citation.
23 """,
24 """\
25 <document source="test data">
26 <citation ids="citation" names="citation">
27 <label>
28 citation
29 <paragraph>
30 This is a citation.
31 """],
32 ["""\
33 .. [citation1234] This is a citation with year.
34 """,
35 """\
36 <document source="test data">
37 <citation ids="citation1234" names="citation1234">
38 <label>
39 citation1234
40 <paragraph>
41 This is a citation with year.
42 """],
43 ["""\
44 .. [citation] This is a citation
45 on multiple lines.
46 """,
47 """\
48 <document source="test data">
49 <citation ids="citation" names="citation">
50 <label>
51 citation
52 <paragraph>
53 This is a citation
54 on multiple lines.
55 """],
56 ["""\
57 .. [citation1] This is a citation
58 on multiple lines with more space.
60 .. [citation2] This is a citation
61 on multiple lines with less space.
62 """,
63 """\
64 <document source="test data">
65 <citation ids="citation1" names="citation1">
66 <label>
67 citation1
68 <paragraph>
69 This is a citation
70 on multiple lines with more space.
71 <citation ids="citation2" names="citation2">
72 <label>
73 citation2
74 <paragraph>
75 This is a citation
76 on multiple lines with less space.
77 """],
78 ["""\
79 .. [citation]
80 This is a citation on multiple lines
81 whose block starts on line 2.
82 """,
83 """\
84 <document source="test data">
85 <citation ids="citation" names="citation">
86 <label>
87 citation
88 <paragraph>
89 This is a citation on multiple lines
90 whose block starts on line 2.
91 """],
92 ["""\
93 .. [citation]
95 That was an empty citation.
96 """,
97 """\
98 <document source="test data">
99 <citation ids="citation" names="citation">
100 <label>
101 citation
102 <paragraph>
103 That was an empty citation.
104 """],
105 ["""\
106 .. [citation]
107 No blank line.
108 """,
109 """\
110 <document source="test data">
111 <citation ids="citation" names="citation">
112 <label>
113 citation
114 <system_message level="2" line="2" source="test data" type="WARNING">
115 <paragraph>
116 Explicit markup ends without a blank line; unexpected unindent.
117 <paragraph>
118 No blank line.
119 """],
120 ["""\
121 .. [citation label with spaces] this isn't a citation
123 .. [*citationlabelwithmarkup*] this isn't a citation
124 """,
125 """\
126 <document source="test data">
127 <comment xml:space="preserve">
128 [citation label with spaces] this isn't a citation
129 <comment xml:space="preserve">
130 [*citationlabelwithmarkup*] this isn't a citation
131 """],
132 ["""
133 isolated internals : ``.-_``.
135 .. [citation.withdot] one dot
137 .. [citation-withdot] one hyphen
139 .. [citation_withunderscore] one underscore
140 """,
141 """<document source="test data">
142 <paragraph>
143 isolated internals : \n\
144 <literal>
147 <citation ids="citation-withdot" names="citation.withdot">
148 <label>
149 citation.withdot
150 <paragraph>
151 one dot
152 <citation ids="id1" names="citation-withdot">
153 <label>
154 citation-withdot
155 <paragraph>
156 one hyphen
157 <citation ids="citation-withunderscore" names="citation_withunderscore">
158 <label>
159 citation_withunderscore
160 <paragraph>
161 one underscore
162 """],
166 if __name__ == '__main__':
167 import unittest
168 unittest.main(defaultTest='suite')