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