»Core Development>Code coverage>Lib/test/test_unicode_identifiers.py

Python code coverage for Lib/test/test_unicode_identifiers.py

#countcontent
1n/aimport unittest
2n/a
3n/aclass PEP3131Test(unittest.TestCase):
4n/a
5n/a def test_valid(self):
6n/a class T:
7n/a ä = 1
8n/a µ = 2 # this is a compatibility character
9n/a 蟒 = 3
10n/a xó „€ = 4
11n/a self.assertEqual(getattr(T, "\xe4"), 1)
12n/a self.assertEqual(getattr(T, "\u03bc"), 2)
13n/a self.assertEqual(getattr(T, '\u87d2'), 3)
14n/a self.assertEqual(getattr(T, 'x\U000E0100'), 4)
15n/a
16n/a def test_non_bmp_normalized(self):
17n/a 𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1
18n/a self.assertIn("Unicode", dir())
19n/a
20n/a def test_invalid(self):
21n/a try:
22n/a from test import badsyntax_3131
23n/a except SyntaxError as s:
24n/a self.assertEqual(str(s),
25n/a "invalid character in identifier (badsyntax_3131.py, line 2)")
26n/a else:
27n/a self.fail("expected exception didn't occur")
28n/a
29n/aif __name__ == "__main__":
30n/a unittest.main()