Back to index

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

List of all members.

Public Member Functions

def test_failed_import_during_compiling
def test_decimal_numeric_consistent
def test_digit_numeric_consistent
def test_bug_1704793
def test_ucd_510
def test_bug_5828
def test_bug_4971
def test_linebreak_7643
def test_UCS4
def setUp
def tearDown

Public Attributes

 db

Detailed Description

Definition at line 221 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 269 of file test_unicodedata.py.

00269 
00270     def test_bug_1704793(self):
00271         self.assertEqual(self.db.lookup("GOTHIC LETTER FAIHU"), '\U00010346')

Here is the call graph for this function:

Definition at line 294 of file test_unicodedata.py.

00294 
00295     def test_bug_4971(self):
00296         # LETTER DZ WITH CARON: DZ, Dz, dz
00297         self.assertEqual("\u01c4".title(), "\u01c5")
00298         self.assertEqual("\u01c5".title(), "\u01c5")
00299         self.assertEqual("\u01c6".title(), "\u01c5")

Here is the call graph for this function:

Definition at line 283 of file test_unicodedata.py.

00283 
00284     def test_bug_5828(self):
00285         self.assertEqual("\u1d79".lower(), "\u1d79")
00286         # Only U+0000 should have U+0000 as its upper/lower/titlecase variant
00287         self.assertEqual(
00288             [
00289                 c for c in range(sys.maxunicode+1)
00290                 if "\x00" in chr(c).lower()+chr(c).upper()+chr(c).title()
00291             ],
00292             [0]
00293         )

Here is the call graph for this function:

Definition at line 243 of file test_unicodedata.py.

00243 
00244     def test_decimal_numeric_consistent(self):
00245         # Test that decimal and numeric are consistent,
00246         # i.e. if a character has a decimal value,
00247         # its numeric value should be the same.
00248         count = 0
00249         for i in range(0x10000):
00250             c = chr(i)
00251             dec = self.db.decimal(c, -1)
00252             if dec != -1:
00253                 self.assertEqual(dec, self.db.numeric(c))
00254                 count += 1
00255         self.assertTrue(count >= 10) # should have tested at least the ASCII digits

Here is the call graph for this function:

Definition at line 256 of file test_unicodedata.py.

00256 
00257     def test_digit_numeric_consistent(self):
00258         # Test that digit and numeric are consistent,
00259         # i.e. if a character has a digit value,
00260         # its numeric value should be the same.
00261         count = 0
00262         for i in range(0x10000):
00263             c = chr(i)
00264             dec = self.db.digit(c, -1)
00265             if dec != -1:
00266                 self.assertEqual(dec, self.db.numeric(c))
00267                 count += 1
00268         self.assertTrue(count >= 10) # should have tested at least the ASCII digits

Here is the call graph for this function:

Definition at line 223 of file test_unicodedata.py.

00223 
00224     def test_failed_import_during_compiling(self):
00225         # Issue 4367
00226         # Decoding \N escapes requires the unicodedata module. If it can't be
00227         # imported, we shouldn't segfault.
00228 
00229         # This program should raise a SyntaxError in the eval.
00230         code = "import sys;" \
00231             "sys.modules['unicodedata'] = None;" \
00232             """eval("'\\\\N{SOFT HYPHEN}'")"""
00233         args = [sys.executable, "-c", code]
00234         # We use a subprocess because the unicodedata module may already have
00235         # been loaded in this process.
00236         popen = subprocess.Popen(args, stderr=subprocess.PIPE)
00237         popen.wait()
00238         self.assertEqual(popen.returncode, 1)
00239         error = "SyntaxError: (unicode error) \\N escapes not supported " \
00240             "(can't load unicodedata module)"
00241         self.assertIn(error, popen.stderr.read().decode("ascii"))
00242         popen.stderr.close()

Here is the call graph for this function:

Definition at line 300 of file test_unicodedata.py.

00300 
00301     def test_linebreak_7643(self):
00302         for i in range(0x10000):
00303             lines = (chr(i) + 'A').splitlines()
00304             if i in (0x0a, 0x0b, 0x0c, 0x0d, 0x85,
00305                      0x1c, 0x1d, 0x1e, 0x2028, 0x2029):
00306                 self.assertEqual(len(lines), 2,
00307                                  r"\u%.4x should be a linebreak" % i)
00308             else:
00309                 self.assertEqual(len(lines), 1,
00310                                  r"\u%.4x should not be a linebreak" % i)

Here is the call graph for this function:

Definition at line 272 of file test_unicodedata.py.

00272 
00273     def test_ucd_510(self):
00274         import unicodedata
00275         # In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0
00276         self.assertTrue(unicodedata.mirrored("\u0f3a"))
00277         self.assertTrue(not unicodedata.ucd_3_2_0.mirrored("\u0f3a"))
00278         # Also, we now have two ways of representing
00279         # the upper-case mapping: as delta, or as absolute value
00280         self.assertTrue("a".upper()=='A')
00281         self.assertTrue("\u1d79".upper()=='\ua77d')
00282         self.assertTrue(".".upper()=='.')

Here is the call graph for this function:

Definition at line 311 of file test_unicodedata.py.

00311 
00312     def test_UCS4(self):
00313         # unicodedata should work with code points outside the BMP
00314         # even on a narrow Unicode build
00315         self.assertEqual(self.db.category("\U0001012A"), "No")
00316         self.assertEqual(self.db.numeric("\U0001012A"), 9000)
00317         self.assertEqual(self.db.decimal("\U0001D7FD"), 7)
00318         self.assertEqual(self.db.digit("\U0001D7FD"), 7)

Here is the call graph for this function:


Member Data Documentation

Definition at line 75 of file test_unicodedata.py.


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