test_east_asian_text.py :  » Development » Docutils » docutils » test » test_parsers » test_rst » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Development » Docutils 
Docutils » docutils » test » test_parsers » test_rst » test_east_asian_text.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# $Id: test_east_asian_text.py 5889 2009-04-01 20:00:21Z gbrandl $
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.

"""
Tests for East Asian text with double-width characters.
"""

from __init__ import DocutilsTestSupport

import unicodedata
try:
    east_asian_width = unicodedata.east_asian_width
except AttributeError:
    east_asian_width = None

from docutils._compat import b

def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    s.generateTests(totest)
    return s

totest = {}

if not east_asian_width:
    print ('test_east_asian_text.py tests skipped; '
           'Python 2.4 or higher required.')
else:
    totest['double-width'] = [
[u"""\
1
=========

2
========
""",
u"""\
<document source="test data">
    <section ids="id1" names="1">
        <title>
            1
    <section ids="id2" names="2">
        <title>
            2
        <system_message level="2" line="5" source="test data" type="WARNING">
            <paragraph>
                Title underline too short.
            <literal_block xml:space="preserve">
                2
                ========
"""],
[ur"""
+-----------------------+
| * :1  |
| * 2         |
+-----------------------+
| \* 1        |
| * 2         |
+-----------------------+
""",
u"""\
<document source="test data">
    <table>
        <tgroup cols="1">
            <colspec colwidth="23">
            <tbody>
                <row>
                    <entry>
                        <bullet_list bullet="*">
                            <list_item>
                                <paragraph>
                                    :1
                            <list_item>
                                <paragraph>
                                    2
                <row>
                    <entry>
                        <paragraph>
                            * 1
                            * 2
"""],
[u"""\
Complex spanning pattern (no edge knows all rows/cols):

+--------+---------------------+
|  |         |
|  +--------------+------+
|        |  |  |
+--------+--------------+  |
|           |  |
+-----------------------+------+
""",
u"""\
<document source="test data">
    <paragraph>
        Complex spanning pattern (no edge knows all rows/cols):
    <table>
        <tgroup cols="3">
            <colspec colwidth="8">
            <colspec colwidth="14">
            <colspec colwidth="6">
            <tbody>
                <row>
                    <entry morerows="1">
                        <paragraph>
                            
                            
                    <entry morecols="1">
                        <paragraph>
                            
                <row>
                    <entry>
                        <paragraph>
                            
                    <entry morerows="1">
                        <paragraph>
                            
                            
                            
                <row>
                    <entry morecols="1">
                        <paragraph>
                            
"""],
[u"""\
=========  =========
1  2
=========  =========

========  =========
1 2
========  =========
""",
u"""\
<document source="test data">
    <table>
        <tgroup cols="2">
            <colspec colwidth="9">
            <colspec colwidth="9">
            <tbody>
                <row>
                    <entry>
                        <paragraph>
                            1
                    <entry>
                        <paragraph>
                            2
    <system_message level="3" line="5" source="test data" type="ERROR">
        <paragraph>
            Malformed table.
            Text in column margin at line offset 1.
        <literal_block xml:space="preserve">
            ========  =========
            1 2
            ========  =========
"""],
[u"""\
Some ambiguous-width characters:

= ===================================
 copyright sign
 registered sign
 left pointing guillemet
 right pointing guillemet
 en-dash
 em-dash
 single turned comma quotation mark 
 single comma quotation mark 
 low single comma quotation mark 
 double turned comma quotation mark 
 double comma quotation mark 
 low double comma quotation mark 
 dagger
 double dagger
 ellipsis
 trade mark sign
 left-right double arrow
= ===================================
""",
b("""\
<document source="test data">
    <paragraph>
        Some ambiguous-width characters:
    <table>
        <tgroup cols="2">
            <colspec colwidth="1">
            <colspec colwidth="35">
            <tbody>
                <row>
                    <entry>
                        <paragraph>
                            \xa9
                    <entry>
                        <paragraph>
                            copyright sign
                <row>
                    <entry>
                        <paragraph>
                            \xae
                    <entry>
                        <paragraph>
                            registered sign
                <row>
                    <entry>
                        <paragraph>
                            \xab
                    <entry>
                        <paragraph>
                            left pointing guillemet
                <row>
                    <entry>
                        <paragraph>
                            \xbb
                    <entry>
                        <paragraph>
                            right pointing guillemet
                <row>
                    <entry>
                        <paragraph>
                            \\u2013
                    <entry>
                        <paragraph>
                            en-dash
                <row>
                    <entry>
                        <paragraph>
                            \\u2014
                    <entry>
                        <paragraph>
                            em-dash
                <row>
                    <entry>
                        <paragraph>
                            \\u2018
                    <entry>
                        <paragraph>
                            single turned comma quotation mark
                <row>
                    <entry>
                        <paragraph>
                            \\u2019
                    <entry>
                        <paragraph>
                            single comma quotation mark
                <row>
                    <entry>
                        <paragraph>
                            \\u201a
                    <entry>
                        <paragraph>
                            low single comma quotation mark
                <row>
                    <entry>
                        <paragraph>
                            \\u201c
                    <entry>
                        <paragraph>
                            double turned comma quotation mark
                <row>
                    <entry>
                        <paragraph>
                            \\u201d
                    <entry>
                        <paragraph>
                            double comma quotation mark
                <row>
                    <entry>
                        <paragraph>
                            \\u201e
                    <entry>
                        <paragraph>
                            low double comma quotation mark
                <row>
                    <entry>
                        <paragraph>
                            \\u2020
                    <entry>
                        <paragraph>
                            dagger
                <row>
                    <entry>
                        <paragraph>
                            \\u2021
                    <entry>
                        <paragraph>
                            double dagger
                <row>
                    <entry>
                        <paragraph>
                            \\u2026
                    <entry>
                        <paragraph>
                            ellipsis
                <row>
                    <entry>
                        <paragraph>
                            \\u2122
                    <entry>
                        <paragraph>
                            trade mark sign
                <row>
                    <entry>
                        <paragraph>
                            \\u21d4
                    <entry>
                        <paragraph>
                            left-right double arrow
""").decode('raw_unicode_escape')],
]
'''
[u"""\
""",
u"""\
"""],
'''


if __name__ == '__main__':
    import unittest
    unittest.main(defaultTest='suite')
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.