Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_unicodedata.UnicodeFunctionsTest Class Reference
Inheritance diagram for test.test_unicodedata.UnicodeFunctionsTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_unicodedata.UnicodeFunctionsTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_function_checksum
def test_digit
def test_numeric
def test_decimal
def test_category
def test_bidirectional
def test_decomposition
def test_mirrored
def test_combining
def test_normalize
def test_pr29
def test_issue10254
def test_east_asian_width
def setUp
def tearDown

Public Attributes

 db

Static Public Attributes

string expectedchecksum = 'c23dfc0b5eaf3ca2aad32d733de96bb182ccda50'

Detailed Description

Definition at line 80 of file test_unicodedata.py.


Member Function Documentation

Definition at line 71 of file test_unicodedata.py.

00071 
00072     def setUp(self):
00073         # In case unicodedata is not available, this will raise an ImportError,
00074         # but the other test cases will still be run
00075         import unicodedata
00076         self.db = unicodedata

Here is the caller graph for this function:

Definition at line 77 of file test_unicodedata.py.

00077 
00078     def tearDown(self):
00079         del self.db

Here is the caller graph for this function:

Definition at line 148 of file test_unicodedata.py.

00148 
00149     def test_bidirectional(self):
00150         self.assertEqual(self.db.bidirectional('\uFFFE'), '')
00151         self.assertEqual(self.db.bidirectional(' '), 'WS')
00152         self.assertEqual(self.db.bidirectional('A'), 'L')
00153         self.assertEqual(self.db.bidirectional('\U00020000'), 'L')
00154 
00155         self.assertRaises(TypeError, self.db.bidirectional)
00156         self.assertRaises(TypeError, self.db.bidirectional, 'xx')

Here is the call graph for this function:

Definition at line 139 of file test_unicodedata.py.

00139 
00140     def test_category(self):
00141         self.assertEqual(self.db.category('\uFFFE'), 'Cn')
00142         self.assertEqual(self.db.category('a'), 'Ll')
00143         self.assertEqual(self.db.category('A'), 'Lu')
00144         self.assertEqual(self.db.category('\U00020000'), 'Lo')
00145 
00146         self.assertRaises(TypeError, self.db.category)
00147         self.assertRaises(TypeError, self.db.category, 'xx')

Here is the call graph for this function:

Definition at line 173 of file test_unicodedata.py.

00173 
00174     def test_combining(self):
00175         self.assertEqual(self.db.combining('\uFFFE'), 0)
00176         self.assertEqual(self.db.combining('a'), 0)
00177         self.assertEqual(self.db.combining('\u20e1'), 230)
00178         self.assertEqual(self.db.combining('\U00020000'), 0)
00179 
00180         self.assertRaises(TypeError, self.db.combining)
00181         self.assertRaises(TypeError, self.db.combining, 'xx')

Here is the call graph for this function:

Definition at line 128 of file test_unicodedata.py.

00128 
00129     def test_decimal(self):
00130         self.assertEqual(self.db.decimal('A',None), None)
00131         self.assertEqual(self.db.decimal('9'), 9)
00132         self.assertEqual(self.db.decimal('\u215b', None), None)
00133         self.assertEqual(self.db.decimal('\u2468', None), None)
00134         self.assertEqual(self.db.decimal('\U00020000', None), None)
00135 
00136         self.assertRaises(TypeError, self.db.decimal)
00137         self.assertRaises(TypeError, self.db.decimal, 'xx')
00138         self.assertRaises(ValueError, self.db.decimal, 'x')

Here is the call graph for this function:

Definition at line 157 of file test_unicodedata.py.

00157 
00158     def test_decomposition(self):
00159         self.assertEqual(self.db.decomposition('\uFFFE'),'')
00160         self.assertEqual(self.db.decomposition('\u00bc'), '<fraction> 0031 2044 0034')
00161 
00162         self.assertRaises(TypeError, self.db.decomposition)
00163         self.assertRaises(TypeError, self.db.decomposition, 'xx')

Here is the call graph for this function:

Definition at line 105 of file test_unicodedata.py.

00105 
00106     def test_digit(self):
00107         self.assertEqual(self.db.digit('A', None), None)
00108         self.assertEqual(self.db.digit('9'), 9)
00109         self.assertEqual(self.db.digit('\u215b', None), None)
00110         self.assertEqual(self.db.digit('\u2468'), 9)
00111         self.assertEqual(self.db.digit('\U00020000', None), None)
00112 
00113         self.assertRaises(TypeError, self.db.digit)
00114         self.assertRaises(TypeError, self.db.digit, 'xx')
00115         self.assertRaises(ValueError, self.db.digit, 'x')

Here is the call graph for this function:

Definition at line 207 of file test_unicodedata.py.

00207 
00208     def test_east_asian_width(self):
00209         eaw = self.db.east_asian_width
00210         self.assertRaises(TypeError, eaw, b'a')
00211         self.assertRaises(TypeError, eaw, bytearray())
00212         self.assertRaises(TypeError, eaw, '')
00213         self.assertRaises(TypeError, eaw, 'ra')
00214         self.assertEqual(eaw('\x1e'), 'N')
00215         self.assertEqual(eaw('\x20'), 'Na')
00216         self.assertEqual(eaw('\uC894'), 'W')
00217         self.assertEqual(eaw('\uFF66'), 'H')
00218         self.assertEqual(eaw('\uFF1F'), 'F')
00219         self.assertEqual(eaw('\u2010'), 'A')
00220         self.assertEqual(eaw('\U00020000'), 'W')

Here is the call graph for this function:

Definition at line 84 of file test_unicodedata.py.

00084 
00085     def test_function_checksum(self):
00086         data = []
00087         h = hashlib.sha1()
00088 
00089         for i in range(0x10000):
00090             char = chr(i)
00091             data = [
00092                 # Properties
00093                 format(self.db.digit(char, -1), '.12g'),
00094                 format(self.db.numeric(char, -1), '.12g'),
00095                 format(self.db.decimal(char, -1), '.12g'),
00096                 self.db.category(char),
00097                 self.db.bidirectional(char),
00098                 self.db.decomposition(char),
00099                 str(self.db.mirrored(char)),
00100                 str(self.db.combining(char)),
00101             ]
00102             h.update(''.join(data).encode("ascii"))
00103         result = h.hexdigest()
00104         self.assertEqual(result, self.expectedchecksum)

Here is the call graph for this function:

Definition at line 201 of file test_unicodedata.py.

00201 
00202     def test_issue10254(self):
00203         # Crash reported in #10254
00204         a = 'C\u0338' * 20  + 'C\u0327'
00205         b = 'C\u0338' * 20  + '\xC7'
00206         self.assertEqual(self.db.normalize('NFC', a), b)

Here is the call graph for this function:

Definition at line 164 of file test_unicodedata.py.

00164 
00165     def test_mirrored(self):
00166         self.assertEqual(self.db.mirrored('\uFFFE'), 0)
00167         self.assertEqual(self.db.mirrored('a'), 0)
00168         self.assertEqual(self.db.mirrored('\u2201'), 1)
00169         self.assertEqual(self.db.mirrored('\U00020000'), 0)
00170 
00171         self.assertRaises(TypeError, self.db.mirrored)
00172         self.assertRaises(TypeError, self.db.mirrored, 'xx')

Here is the call graph for this function:

Definition at line 182 of file test_unicodedata.py.

00182 
00183     def test_normalize(self):
00184         self.assertRaises(TypeError, self.db.normalize)
00185         self.assertRaises(ValueError, self.db.normalize, 'unknown', 'xx')
00186         self.assertEqual(self.db.normalize('NFKC', ''), '')
00187         # The rest can be found in test_normalization.py
00188         # which requires an external file.

Here is the call graph for this function:

Definition at line 116 of file test_unicodedata.py.

00116 
00117     def test_numeric(self):
00118         self.assertEqual(self.db.numeric('A',None), None)
00119         self.assertEqual(self.db.numeric('9'), 9)
00120         self.assertEqual(self.db.numeric('\u215b'), 0.125)
00121         self.assertEqual(self.db.numeric('\u2468'), 9.0)
00122         self.assertEqual(self.db.numeric('\ua627'), 7.0)
00123         self.assertEqual(self.db.numeric('\U00020000', None), None)
00124 
00125         self.assertRaises(TypeError, self.db.numeric)
00126         self.assertRaises(TypeError, self.db.numeric, 'xx')
00127         self.assertRaises(ValueError, self.db.numeric, 'x')

Here is the call graph for this function:

Definition at line 189 of file test_unicodedata.py.

00189 
00190     def test_pr29(self):
00191         # http://www.unicode.org/review/pr-29.html
00192         # See issues #1054943 and #10254.
00193         composed = ("\u0b47\u0300\u0b3e", "\u1100\u0300\u1161",
00194                     'Li\u030dt-s\u1e73\u0301',
00195                     '\u092e\u093e\u0930\u094d\u0915 \u091c\u093c'
00196                     + '\u0941\u0915\u0947\u0930\u092c\u0930\u094d\u0917',
00197                     '\u0915\u093f\u0930\u094d\u0917\u093f\u091c\u093c'
00198                     + '\u0938\u094d\u0924\u093e\u0928')
00199         for text in composed:
00200             self.assertEqual(self.db.normalize('NFC', text), text)

Here is the call graph for this function:


Member Data Documentation

Definition at line 75 of file test_unicodedata.py.

string test.test_unicodedata.UnicodeFunctionsTest.expectedchecksum = 'c23dfc0b5eaf3ca2aad32d733de96bb182ccda50' [static]

Definition at line 83 of file test_unicodedata.py.


The documentation for this class was generated from the following file: