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

« back to all changes in this revision

Viewing changes to test/test_parsers/test_rst/test_east_asian_text.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
# -*- coding: utf-8 -*-
 
3
 
 
4
# Author: David Goodger
 
5
# Contact: goodger@python.org
 
6
# Revision: $Revision: 4152 $
 
7
# Date: $Date: 2005-12-08 00:46:30 +0100 (Thu, 08 Dec 2005) $
 
8
# Copyright: This module has been placed in the public domain.
 
9
 
 
10
"""
 
11
Tests for East Asian text with double-width characters.
 
12
"""
 
13
 
 
14
from __init__ import DocutilsTestSupport
 
15
 
 
16
import unicodedata
 
17
try:
 
18
    east_asian_width = unicodedata.east_asian_width
 
19
except AttributeError:
 
20
    east_asian_width = None
 
21
 
 
22
def suite():
 
23
    s = DocutilsTestSupport.ParserTestSuite()
 
24
    s.generateTests(totest)
 
25
    return s
 
26
 
 
27
totest = {}
 
28
 
 
29
if not east_asian_width:
 
30
    print ('test_east_asian_text.py tests skipped; '
 
31
           'Python 2.4 or higher required.')
 
32
else:
 
33
    totest['double-width'] = [
 
34
[u"""\
 
35
タイトル1
 
36
=========
 
37
 
 
38
タイトル2
 
39
========
 
40
""",
 
41
u"""\
 
42
<document source="test data">
 
43
    <section ids="id1" names="タイトル1">
 
44
        <title>
 
45
            タイトル1
 
46
    <section ids="id2" names="タイトル2">
 
47
        <title>
 
48
            タイトル2
 
49
        <system_message level="2" line="5" source="test data" type="WARNING">
 
50
            <paragraph>
 
51
                Title underline too short.
 
52
            <literal_block xml:space="preserve">
 
53
                タイトル2
 
54
                ========
 
55
"""],
 
56
[ur"""
 
57
+-----------------------+
 
58
| * ヒョウ:ダイ1ギョウ  |
 
59
| * ダイ2ギョウ         |
 
60
+-----------------------+
 
61
| \* ダイ1ギョウ        |
 
62
| * ダイ2ギョウ         |
 
63
+-----------------------+
 
64
""",
 
65
u"""\
 
66
<document source="test data">
 
67
    <table>
 
68
        <tgroup cols="1">
 
69
            <colspec colwidth="23">
 
70
            <tbody>
 
71
                <row>
 
72
                    <entry>
 
73
                        <bullet_list bullet="*">
 
74
                            <list_item>
 
75
                                <paragraph>
 
76
                                    ヒョウ:ダイ1ギョウ
 
77
                            <list_item>
 
78
                                <paragraph>
 
79
                                    ダイ2ギョウ
 
80
                <row>
 
81
                    <entry>
 
82
                        <paragraph>
 
83
                            * ダイ1ギョウ
 
84
                            * ダイ2ギョウ
 
85
"""],
 
86
[u"""\
 
87
Complex spanning pattern (no edge knows all rows/cols):
 
88
 
 
89
+--------+---------------------+
 
90
| 北西・ | 北・北東セル        |
 
91
| 西セル +--------------+------+
 
92
|        | 真ん中のセル | 東・ |
 
93
+--------+--------------+ 南東 |
 
94
| 南西・南セル          | セル |
 
95
+-----------------------+------+
 
96
""",
 
97
u"""\
 
98
<document source="test data">
 
99
    <paragraph>
 
100
        Complex spanning pattern (no edge knows all rows/cols):
 
101
    <table>
 
102
        <tgroup cols="3">
 
103
            <colspec colwidth="8">
 
104
            <colspec colwidth="14">
 
105
            <colspec colwidth="6">
 
106
            <tbody>
 
107
                <row>
 
108
                    <entry morerows="1">
 
109
                        <paragraph>
 
110
                            北西・
 
111
                            西セル
 
112
                    <entry morecols="1">
 
113
                        <paragraph>
 
114
                            北・北東セル
 
115
                <row>
 
116
                    <entry>
 
117
                        <paragraph>
 
118
                            真ん中のセル
 
119
                    <entry morerows="1">
 
120
                        <paragraph>
 
121
                            東・
 
122
                            南東
 
123
                            セル
 
124
                <row>
 
125
                    <entry morecols="1">
 
126
                        <paragraph>
 
127
                            南西・南セル
 
128
"""],
 
129
[u"""\
 
130
=========  =========
 
131
ダイ1ラン  ダイ2ラン
 
132
=========  =========
 
133
 
 
134
========  =========
 
135
ダイ1ラン ダイ2ラン
 
136
========  =========
 
137
""",
 
138
u"""\
 
139
<document source="test data">
 
140
    <table>
 
141
        <tgroup cols="2">
 
142
            <colspec colwidth="9">
 
143
            <colspec colwidth="9">
 
144
            <tbody>
 
145
                <row>
 
146
                    <entry>
 
147
                        <paragraph>
 
148
                            ダイ1ラン
 
149
                    <entry>
 
150
                        <paragraph>
 
151
                            ダイ2ラン
 
152
    <system_message level="3" line="5" source="test data" type="ERROR">
 
153
        <paragraph>
 
154
            Malformed table.
 
155
            Text in column margin at line offset 1.
 
156
        <literal_block xml:space="preserve">
 
157
            ========  =========
 
158
            ダイ1ラン ダイ2ラン
 
159
            ========  =========
 
160
"""],
 
161
[u"""\
 
162
Some ambiguous-width characters:
 
163
 
 
164
= ===================================
 
165
© copyright sign
 
166
® registered sign
 
167
« left pointing guillemet
 
168
» right pointing guillemet
 
169
– en-dash
 
170
— em-dash
 
171
‘ single turned comma quotation mark 
 
172
’ single comma quotation mark 
 
173
‚ low single comma quotation mark 
 
174
“ double turned comma quotation mark 
 
175
” double comma quotation mark 
 
176
„ low double comma quotation mark 
 
177
† dagger
 
178
‡ double dagger
 
179
… ellipsis
 
180
™ trade mark sign
 
181
⇔ left-right double arrow
 
182
= ===================================
 
183
""",
 
184
u"""\
 
185
<document source="test data">
 
186
    <paragraph>
 
187
        Some ambiguous-width characters:
 
188
    <table>
 
189
        <tgroup cols="2">
 
190
            <colspec colwidth="1">
 
191
            <colspec colwidth="35">
 
192
            <tbody>
 
193
                <row>
 
194
                    <entry>
 
195
                        <paragraph>
 
196
                            \xa9
 
197
                    <entry>
 
198
                        <paragraph>
 
199
                            copyright sign
 
200
                <row>
 
201
                    <entry>
 
202
                        <paragraph>
 
203
                            \xae
 
204
                    <entry>
 
205
                        <paragraph>
 
206
                            registered sign
 
207
                <row>
 
208
                    <entry>
 
209
                        <paragraph>
 
210
                            \xab
 
211
                    <entry>
 
212
                        <paragraph>
 
213
                            left pointing guillemet
 
214
                <row>
 
215
                    <entry>
 
216
                        <paragraph>
 
217
                            \xbb
 
218
                    <entry>
 
219
                        <paragraph>
 
220
                            right pointing guillemet
 
221
                <row>
 
222
                    <entry>
 
223
                        <paragraph>
 
224
                            \\u2013
 
225
                    <entry>
 
226
                        <paragraph>
 
227
                            en-dash
 
228
                <row>
 
229
                    <entry>
 
230
                        <paragraph>
 
231
                            \\u2014
 
232
                    <entry>
 
233
                        <paragraph>
 
234
                            em-dash
 
235
                <row>
 
236
                    <entry>
 
237
                        <paragraph>
 
238
                            \\u2018
 
239
                    <entry>
 
240
                        <paragraph>
 
241
                            single turned comma quotation mark
 
242
                <row>
 
243
                    <entry>
 
244
                        <paragraph>
 
245
                            \\u2019
 
246
                    <entry>
 
247
                        <paragraph>
 
248
                            single comma quotation mark
 
249
                <row>
 
250
                    <entry>
 
251
                        <paragraph>
 
252
                            \\u201a
 
253
                    <entry>
 
254
                        <paragraph>
 
255
                            low single comma quotation mark
 
256
                <row>
 
257
                    <entry>
 
258
                        <paragraph>
 
259
                            \\u201c
 
260
                    <entry>
 
261
                        <paragraph>
 
262
                            double turned comma quotation mark
 
263
                <row>
 
264
                    <entry>
 
265
                        <paragraph>
 
266
                            \\u201d
 
267
                    <entry>
 
268
                        <paragraph>
 
269
                            double comma quotation mark
 
270
                <row>
 
271
                    <entry>
 
272
                        <paragraph>
 
273
                            \\u201e
 
274
                    <entry>
 
275
                        <paragraph>
 
276
                            low double comma quotation mark
 
277
                <row>
 
278
                    <entry>
 
279
                        <paragraph>
 
280
                            \\u2020
 
281
                    <entry>
 
282
                        <paragraph>
 
283
                            dagger
 
284
                <row>
 
285
                    <entry>
 
286
                        <paragraph>
 
287
                            \\u2021
 
288
                    <entry>
 
289
                        <paragraph>
 
290
                            double dagger
 
291
                <row>
 
292
                    <entry>
 
293
                        <paragraph>
 
294
                            \\u2026
 
295
                    <entry>
 
296
                        <paragraph>
 
297
                            ellipsis
 
298
                <row>
 
299
                    <entry>
 
300
                        <paragraph>
 
301
                            \\u2122
 
302
                    <entry>
 
303
                        <paragraph>
 
304
                            trade mark sign
 
305
                <row>
 
306
                    <entry>
 
307
                        <paragraph>
 
308
                            \\u21d4
 
309
                    <entry>
 
310
                        <paragraph>
 
311
                            left-right double arrow
 
312
"""],
 
313
]
 
314
'''
 
315
[u"""\
 
316
""",
 
317
u"""\
 
318
"""],
 
319
'''
 
320
 
 
321
 
 
322
if __name__ == '__main__':
 
323
    import unittest
 
324
    unittest.main(defaultTest='suite')