make file closing more robust
[python/dscho.git] / Lib / test / test_pep3131.py
blobe4c2d031e20ac4f7da694e7a3d4941fa24773e19
1 # -*- coding: utf-8 -*-
2 import unittest
3 from test import support
5 class PEP3131Test(unittest.TestCase):
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)
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")
25 def test_main():
26 support.run_unittest(PEP3131Test)
28 if __name__=="__main__":
29 test_main()