Martin v. Löwis | 4738340 | 2007-08-15 07:32:56 +0000 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | import unittest |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 3 | from test import support |
Martin v. Löwis | 4738340 | 2007-08-15 07:32:56 +0000 | [diff] [blame] | 4 | |
| 5 | class PEP3131Test(unittest.TestCase): |
| 6 | |
| 7 | def test_valid(self): |
| 8 | class T: |
| 9 | ä = 1 |
| 10 | µ = 2 # this is a compatibility character |
| 11 | 蟒 = 3 |
| 12 | self.assertEquals(getattr(T, "\xe4"), 1) |
| 13 | self.assertEquals(getattr(T, "\u03bc"), 2) |
| 14 | self.assertEquals(getattr(T, '\u87d2'), 3) |
| 15 | |
| 16 | def test_invalid(self): |
| 17 | try: |
| 18 | from test import badsyntax_3131 |
| 19 | except SyntaxError as s: |
| 20 | self.assertEquals(str(s), |
| 21 | "invalid character in identifier (badsyntax_3131.py, line 2)") |
| 22 | else: |
| 23 | self.fail("expected exception didn't occur") |
| 24 | |
| 25 | def test_main(): |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 26 | support.run_unittest(PEP3131Test) |
Martin v. Löwis | 4738340 | 2007-08-15 07:32:56 +0000 | [diff] [blame] | 27 | |
| 28 | if __name__=="__main__": |
| 29 | test_main() |