blob: 2e6b90a35c63a67ee2237b6620affc8502de8221 [file] [log] [blame]
Martin v. Löwis47383402007-08-15 07:32:56 +00001import unittest
Benjamin Petersonbe662872011-08-12 23:35:34 -05002import sys
Benjamin Petersonee8712c2008-05-20 21:35:26 +00003from test import support
Martin v. Löwis47383402007-08-15 07:32:56 +00004
5class PEP3131Test(unittest.TestCase):
6
7 def test_valid(self):
8 class T:
9 ä = 1
10 µ = 2 # this is a compatibility character
11 = 3
Benjamin Petersonbe662872011-08-12 23:35:34 -050012 x󠄀 = 4
Ezio Melottib3aedd42010-11-20 19:04:17 +000013 self.assertEqual(getattr(T, "\xe4"), 1)
14 self.assertEqual(getattr(T, "\u03bc"), 2)
15 self.assertEqual(getattr(T, '\u87d2'), 3)
Benjamin Petersonbe662872011-08-12 23:35:34 -050016 self.assertEqual(getattr(T, 'x\U000E0100'), 4)
17
18 def test_non_bmp_normalized(self):
19 𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1
Martin v. Löwisff1ef072011-09-29 13:49:10 +020020 self.assertIn("Unicode", dir())
Martin v. Löwis47383402007-08-15 07:32:56 +000021
22 def test_invalid(self):
23 try:
24 from test import badsyntax_3131
25 except SyntaxError as s:
Ezio Melottib3aedd42010-11-20 19:04:17 +000026 self.assertEqual(str(s),
Martin v. Löwis47383402007-08-15 07:32:56 +000027 "invalid character in identifier (badsyntax_3131.py, line 2)")
28 else:
29 self.fail("expected exception didn't occur")
30
31def test_main():
Benjamin Petersonee8712c2008-05-20 21:35:26 +000032 support.run_unittest(PEP3131Test)
Martin v. Löwis47383402007-08-15 07:32:56 +000033
34if __name__=="__main__":
35 test_main()