1 | n/a | import unittest |
---|
2 | n/a | |
---|
3 | n/a | class PEP3131Test(unittest.TestCase): |
---|
4 | n/a | |
---|
5 | n/a | def test_valid(self): |
---|
6 | n/a | class T: |
---|
7 | n/a | ä = 1 |
---|
8 | n/a | µ = 2 # this is a compatibility character |
---|
9 | n/a | è = 3 |
---|
10 | n/a | xó = 4 |
---|
11 | n/a | self.assertEqual(getattr(T, "\xe4"), 1) |
---|
12 | n/a | self.assertEqual(getattr(T, "\u03bc"), 2) |
---|
13 | n/a | self.assertEqual(getattr(T, '\u87d2'), 3) |
---|
14 | n/a | self.assertEqual(getattr(T, 'x\U000E0100'), 4) |
---|
15 | n/a | |
---|
16 | n/a | def test_non_bmp_normalized(self): |
---|
17 | n/a | ðð«ð¦ð ð¬ð¡ð¢ = 1 |
---|
18 | n/a | self.assertIn("Unicode", dir()) |
---|
19 | n/a | |
---|
20 | n/a | def test_invalid(self): |
---|
21 | n/a | try: |
---|
22 | n/a | from test import badsyntax_3131 |
---|
23 | n/a | except SyntaxError as s: |
---|
24 | n/a | self.assertEqual(str(s), |
---|
25 | n/a | "invalid character in identifier (badsyntax_3131.py, line 2)") |
---|
26 | n/a | else: |
---|
27 | n/a | self.fail("expected exception didn't occur") |
---|
28 | n/a | |
---|
29 | n/a | if __name__ == "__main__": |
---|
30 | n/a | unittest.main() |
---|