Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_unicodedata.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 355beb0bd02b |
| children | 8f1202ca888e 6768b2350c57 |
| rev | line source |
|---|---|
| 12074 | 1 """ Test script for the unicodedata module. |
| 2 | |
|
14875
17b5c43c08a6
Added test suite for the complete Unicode database. The test previously
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
3 Written by Marc-Andre Lemburg (mal@lemburg.com). |
| 12074 | 4 |
|
14875
17b5c43c08a6
Added test suite for the complete Unicode database. The test previously
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
5 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. |
| 12074 | 6 |
|
49796
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
7 """ |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
8 |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
9 import sys |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
10 import unittest |
|
38052
32a187f3d5ba
In stdlib, use hashlib instead of deprecated md5 and sha modules.
Georg Brandl <georg@python.org>
parents:
36924
diff
changeset
|
11 import hashlib |
|
49796
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
12 import subprocess |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
13 import test.test_support |
|
14875
17b5c43c08a6
Added test suite for the complete Unicode database. The test previously
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
14 |
|
14896
ad98c136475e
Fixed encoding to use an endianness independent format.
Marc-André Lemburg <mal@egenix.com>
parents:
14875
diff
changeset
|
15 encoding = 'utf-8' |
|
ad98c136475e
Fixed encoding to use an endianness independent format.
Marc-André Lemburg <mal@egenix.com>
parents:
14875
diff
changeset
|
16 |
|
14875
17b5c43c08a6
Added test suite for the complete Unicode database. The test previously
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
17 |
|
17b5c43c08a6
Added test suite for the complete Unicode database. The test previously
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
18 ### Run tests |
|
17b5c43c08a6
Added test suite for the complete Unicode database. The test previously
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
19 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
20 class UnicodeMethodsTest(unittest.TestCase): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
21 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
22 # update this, if the database changes |
|
53450
c92e93a54298
Merged revisions 71947 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
53400
diff
changeset
|
23 expectedchecksum = '6ec65b65835614ec00634c674bba0e50cd32c189' |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
24 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
25 def test_method_checksum(self): |
|
38052
32a187f3d5ba
In stdlib, use hashlib instead of deprecated md5 and sha modules.
Georg Brandl <georg@python.org>
parents:
36924
diff
changeset
|
26 h = hashlib.sha1() |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
27 for i in range(65536): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
28 char = unichr(i) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
29 data = [ |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
30 # Predicates (single char) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
31 u"01"[char.isalnum()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
32 u"01"[char.isalpha()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
33 u"01"[char.isdecimal()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
34 u"01"[char.isdigit()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
35 u"01"[char.islower()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
36 u"01"[char.isnumeric()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
37 u"01"[char.isspace()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
38 u"01"[char.istitle()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
39 u"01"[char.isupper()], |
|
14875
17b5c43c08a6
Added test suite for the complete Unicode database. The test previously
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
40 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
41 # Predicates (multiple chars) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
42 u"01"[(char + u'abc').isalnum()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
43 u"01"[(char + u'abc').isalpha()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
44 u"01"[(char + u'123').isdecimal()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
45 u"01"[(char + u'123').isdigit()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
46 u"01"[(char + u'abc').islower()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
47 u"01"[(char + u'123').isnumeric()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
48 u"01"[(char + u' \t').isspace()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
49 u"01"[(char + u'abc').istitle()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
50 u"01"[(char + u'ABC').isupper()], |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
51 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
52 # Mappings (single char) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
53 char.lower(), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
54 char.upper(), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
55 char.title(), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
56 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
57 # Mappings (multiple chars) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
58 (char + u'abc').lower(), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
59 (char + u'ABC').upper(), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
60 (char + u'abc').title(), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
61 (char + u'ABC').title(), |
| 12074 | 62 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
63 ] |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
64 h.update(u''.join(data).encode(encoding)) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
65 result = h.hexdigest() |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
66 self.assertEqual(result, self.expectedchecksum) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
67 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
68 class UnicodeDatabaseTest(unittest.TestCase): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
69 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
70 def setUp(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
71 # In case unicodedata is not available, this will raise an ImportError, |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
72 # but the other test cases will still be run |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
73 import unicodedata |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
74 self.db = unicodedata |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
75 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
76 def tearDown(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
77 del self.db |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
78 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
79 class UnicodeFunctionsTest(UnicodeDatabaseTest): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
80 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
81 # update this, if the database changes |
|
49124
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
82 expectedchecksum = '3136d5afd787dc2bcb1bdcac95e385349fbebbca' |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
83 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
84 def test_function_checksum(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
85 data = [] |
|
38052
32a187f3d5ba
In stdlib, use hashlib instead of deprecated md5 and sha modules.
Georg Brandl <georg@python.org>
parents:
36924
diff
changeset
|
86 h = hashlib.sha1() |
| 12074 | 87 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
88 for i in range(0x10000): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
89 char = unichr(i) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
90 data = [ |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
91 # Properties |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
92 str(self.db.digit(char, -1)), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
93 str(self.db.numeric(char, -1)), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
94 str(self.db.decimal(char, -1)), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
95 self.db.category(char), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
96 self.db.bidirectional(char), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
97 self.db.decomposition(char), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
98 str(self.db.mirrored(char)), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
99 str(self.db.combining(char)), |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
100 ] |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
101 h.update(''.join(data)) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
102 result = h.hexdigest() |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
103 self.assertEqual(result, self.expectedchecksum) |
| 12074 | 104 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
105 def test_digit(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
106 self.assertEqual(self.db.digit(u'A', None), None) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
107 self.assertEqual(self.db.digit(u'9'), 9) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
108 self.assertEqual(self.db.digit(u'\u215b', None), None) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
109 self.assertEqual(self.db.digit(u'\u2468'), 9) |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
110 self.assertEqual(self.db.digit(u'\U00020000', None), None) |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
111 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
112 self.assertRaises(TypeError, self.db.digit) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
113 self.assertRaises(TypeError, self.db.digit, u'xx') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
114 self.assertRaises(ValueError, self.db.digit, u'x') |
| 12074 | 115 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
116 def test_numeric(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
117 self.assertEqual(self.db.numeric(u'A',None), None) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
118 self.assertEqual(self.db.numeric(u'9'), 9) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
119 self.assertEqual(self.db.numeric(u'\u215b'), 0.125) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
120 self.assertEqual(self.db.numeric(u'\u2468'), 9.0) |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
121 self.assertEqual(self.db.numeric(u'\U00020000', None), None) |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
122 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
123 self.assertRaises(TypeError, self.db.numeric) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
124 self.assertRaises(TypeError, self.db.numeric, u'xx') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
125 self.assertRaises(ValueError, self.db.numeric, u'x') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
126 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
127 def test_decimal(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
128 self.assertEqual(self.db.decimal(u'A',None), None) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
129 self.assertEqual(self.db.decimal(u'9'), 9) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
130 self.assertEqual(self.db.decimal(u'\u215b', None), None) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
131 self.assertEqual(self.db.decimal(u'\u2468', None), None) |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
132 self.assertEqual(self.db.decimal(u'\U00020000', None), None) |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
133 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
134 self.assertRaises(TypeError, self.db.decimal) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
135 self.assertRaises(TypeError, self.db.decimal, u'xx') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
136 self.assertRaises(ValueError, self.db.decimal, u'x') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
137 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
138 def test_category(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
139 self.assertEqual(self.db.category(u'\uFFFE'), 'Cn') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
140 self.assertEqual(self.db.category(u'a'), 'Ll') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
141 self.assertEqual(self.db.category(u'A'), 'Lu') |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
142 self.assertEqual(self.db.category(u'\U00020000'), 'Lo') |
| 12074 | 143 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
144 self.assertRaises(TypeError, self.db.category) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
145 self.assertRaises(TypeError, self.db.category, u'xx') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
146 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
147 def test_bidirectional(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
148 self.assertEqual(self.db.bidirectional(u'\uFFFE'), '') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
149 self.assertEqual(self.db.bidirectional(u' '), 'WS') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
150 self.assertEqual(self.db.bidirectional(u'A'), 'L') |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
151 self.assertEqual(self.db.bidirectional(u'\U00020000'), 'L') |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
152 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
153 self.assertRaises(TypeError, self.db.bidirectional) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
154 self.assertRaises(TypeError, self.db.bidirectional, u'xx') |
| 12074 | 155 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
156 def test_decomposition(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
157 self.assertEqual(self.db.decomposition(u'\uFFFE'),'') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
158 self.assertEqual(self.db.decomposition(u'\u00bc'), '<fraction> 0031 2044 0034') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
159 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
160 self.assertRaises(TypeError, self.db.decomposition) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
161 self.assertRaises(TypeError, self.db.decomposition, u'xx') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
162 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
163 def test_mirrored(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
164 self.assertEqual(self.db.mirrored(u'\uFFFE'), 0) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
165 self.assertEqual(self.db.mirrored(u'a'), 0) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
166 self.assertEqual(self.db.mirrored(u'\u2201'), 1) |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
167 self.assertEqual(self.db.mirrored(u'\U00020000'), 0) |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
168 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
169 self.assertRaises(TypeError, self.db.mirrored) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
170 self.assertRaises(TypeError, self.db.mirrored, u'xx') |
| 12074 | 171 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
172 def test_combining(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
173 self.assertEqual(self.db.combining(u'\uFFFE'), 0) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
174 self.assertEqual(self.db.combining(u'a'), 0) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
175 self.assertEqual(self.db.combining(u'\u20e1'), 230) |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
176 self.assertEqual(self.db.combining(u'\U00020000'), 0) |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
177 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
178 self.assertRaises(TypeError, self.db.combining) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
179 self.assertRaises(TypeError, self.db.combining, u'xx') |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
180 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
181 def test_normalize(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
182 self.assertRaises(TypeError, self.db.normalize) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
183 self.assertRaises(ValueError, self.db.normalize, 'unknown', u'xx') |
|
31930
f8c0ac5bef02
Special case normalization of empty strings. Fixes #924361.
Martin v. Löwis <martin@v.loewis.de>
parents:
28917
diff
changeset
|
184 self.assertEqual(self.db.normalize('NFKC', u''), u'') |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
185 # The rest can be found in test_normalization.py |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
186 # which requires an external file. |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
187 |
|
32951
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
188 def test_east_asian_width(self): |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
189 eaw = self.db.east_asian_width |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
190 self.assertRaises(TypeError, eaw, 'a') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
191 self.assertRaises(TypeError, eaw, u'') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
192 self.assertRaises(TypeError, eaw, u'ra') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
193 self.assertEqual(eaw(u'\x1e'), 'N') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
194 self.assertEqual(eaw(u'\x20'), 'Na') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
195 self.assertEqual(eaw(u'\uC894'), 'W') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
196 self.assertEqual(eaw(u'\uFF66'), 'H') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
197 self.assertEqual(eaw(u'\uFF1F'), 'F') |
|
024ff0ab4588
SF #989185: Drop unicode.iswide() and unicode.width() and add
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31930
diff
changeset
|
198 self.assertEqual(eaw(u'\u2010'), 'A') |
|
47451
ed471a8009a6
Change all functions that expect one unicode character to accept a pair of
Walter Dörwald <walter@livinglogic.de>
parents:
42387
diff
changeset
|
199 self.assertEqual(eaw(u'\U00020000'), 'W') |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
200 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
201 class UnicodeMiscTest(UnicodeDatabaseTest): |
| 12074 | 202 |
|
49796
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
203 def test_failed_import_during_compiling(self): |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
204 # Issue 4367 |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
205 # Decoding \N escapes requires the unicodedata module. If it can't be |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
206 # imported, we shouldn't segfault. |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
207 |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
208 # This program should raise a SyntaxError in the eval. |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
209 code = "import sys;" \ |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
210 "sys.modules['unicodedata'] = None;" \ |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
211 """eval("u'\N{SOFT HYPHEN}'")""" |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
212 args = [sys.executable, "-c", code] |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
213 # We use a subprocess because the unicodedata module may already have |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
214 # been loaded in this process. |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
215 popen = subprocess.Popen(args, stderr=subprocess.PIPE) |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
216 popen.wait() |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
217 self.assertEqual(popen.returncode, 1) |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
218 error = "SyntaxError: (unicode error) \N escapes not supported " \ |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
219 "(can't load unicodedata module)" |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
220 self.assertTrue(error in popen.stderr.read()) |
|
0bcafa64eccb
Merged revisions 67320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49124
diff
changeset
|
221 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
222 def test_decimal_numeric_consistent(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
223 # Test that decimal and numeric are consistent, |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
224 # i.e. if a character has a decimal value, |
|
35276
4adbd331d335
Fix all wrong instances of "it's".
Georg Brandl <georg@python.org>
parents:
32951
diff
changeset
|
225 # its numeric value should be the same. |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
226 count = 0 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
227 for i in xrange(0x10000): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
228 c = unichr(i) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
229 dec = self.db.decimal(c, -1) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
230 if dec != -1: |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
231 self.assertEqual(dec, self.db.numeric(c)) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
232 count += 1 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
233 self.assert_(count >= 10) # should have tested at least the ASCII digits |
| 12074 | 234 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
235 def test_digit_numeric_consistent(self): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
236 # Test that digit and numeric are consistent, |
|
28231
4cafa5141012
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
28075
diff
changeset
|
237 # i.e. if a character has a digit value, |
|
35276
4adbd331d335
Fix all wrong instances of "it's".
Georg Brandl <georg@python.org>
parents:
32951
diff
changeset
|
238 # its numeric value should be the same. |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
239 count = 0 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
240 for i in xrange(0x10000): |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
241 c = unichr(i) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
242 dec = self.db.digit(c, -1) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
243 if dec != -1: |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
244 self.assertEqual(dec, self.db.numeric(c)) |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
245 count += 1 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
246 self.assert_(count >= 10) # should have tested at least the ASCII digits |
| 12074 | 247 |
|
42387
85b7f40e1c1c
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
Martin v. Löwis <martin@v.loewis.de>
parents:
38422
diff
changeset
|
248 def test_bug_1704793(self): |
|
85b7f40e1c1c
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
Martin v. Löwis <martin@v.loewis.de>
parents:
38422
diff
changeset
|
249 self.assertEquals(self.db.lookup("GOTHIC LETTER FAIHU"), u'\U00010346') |
|
85b7f40e1c1c
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
Martin v. Löwis <martin@v.loewis.de>
parents:
38422
diff
changeset
|
250 |
|
49124
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
251 def test_ucd_510(self): |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
252 import unicodedata |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
253 # In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0 |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
254 self.assert_(unicodedata.mirrored(u"\u0f3a")) |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
255 self.assert_(not unicodedata.ucd_3_2_0.mirrored(u"\u0f3a")) |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
256 # Also, we now have two ways of representing |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
257 # the upper-case mapping: as delta, or as absolute value |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
258 self.assert_(u"a".upper()==u'A') |
|
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
259 self.assert_(u"\u1d79".upper()==u'\ua77d') |
|
53400
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
260 self.assert_(u".".upper()==u".") |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
261 |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
262 def test_bug_5828(self): |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
263 self.assertEqual(u"\u1d79".lower(), u"\u1d79") |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
264 # Only U+0000 should have U+0000 as its upper/lower/titlecase variant |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
265 self.assertEqual( |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
266 [ |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
267 c for c in range(sys.maxunicode+1) |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
268 if u"\x00" in unichr(c).lower()+unichr(c).upper()+unichr(c).title() |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
269 ], |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
270 [0] |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
271 ) |
|
f08f776082ec
Merged revisions 71894 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
49796
diff
changeset
|
272 |
|
53474
355beb0bd02b
Merged revisions 71972 via svnmerge from
Walter Dörwald <walter@livinglogic.de>
parents:
53450
diff
changeset
|
273 def test_bug_4971(self): |
|
53450
c92e93a54298
Merged revisions 71947 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
53400
diff
changeset
|
274 # LETTER DZ WITH CARON: DZ, Dz, dz |
|
c92e93a54298
Merged revisions 71947 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
53400
diff
changeset
|
275 self.assertEqual(u"\u01c4".title(), u"\u01c5") |
|
c92e93a54298
Merged revisions 71947 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
53400
diff
changeset
|
276 self.assertEqual(u"\u01c5".title(), u"\u01c5") |
|
c92e93a54298
Merged revisions 71947 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
53400
diff
changeset
|
277 self.assertEqual(u"\u01c6".title(), u"\u01c5") |
|
49124
c37c7dbd7880
Issue #3811: The Unicode database was updated to 5.1.
Martin v. Löwis <martin@v.loewis.de>
parents:
47451
diff
changeset
|
278 |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
279 def test_main(): |
|
28917
1741af48fd9f
Combine the functionality of test_support.run_unittest()
Walter Dörwald <walter@livinglogic.de>
parents:
28231
diff
changeset
|
280 test.test_support.run_unittest( |
|
1741af48fd9f
Combine the functionality of test_support.run_unittest()
Walter Dörwald <walter@livinglogic.de>
parents:
28231
diff
changeset
|
281 UnicodeMiscTest, |
|
1741af48fd9f
Combine the functionality of test_support.run_unittest()
Walter Dörwald <walter@livinglogic.de>
parents:
28231
diff
changeset
|
282 UnicodeMethodsTest, |
|
1741af48fd9f
Combine the functionality of test_support.run_unittest()
Walter Dörwald <walter@livinglogic.de>
parents:
28231
diff
changeset
|
283 UnicodeFunctionsTest |
|
1741af48fd9f
Combine the functionality of test_support.run_unittest()
Walter Dörwald <walter@livinglogic.de>
parents:
28231
diff
changeset
|
284 ) |
|
28075
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
285 |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
286 if __name__ == "__main__": |
|
7fdcc4cfc759
Port test_ucn and test_unicodedata to PyUnit. Add a few tests for error
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
287 test_main() |
