blob: 3f567bf588372d1c1d3e88318088710bde1a4858 [file] [log] [blame]
Martin v. Löwis447d33e2007-07-29 18:10:01 +00001# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
2
3import unittest
4from test import test_support
5
6class PEP3120Test(unittest.TestCase):
7
8 def test_pep3120(self):
9 self.assertEqual(
10 "Питон".encode("utf-8"),
11 b'\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd'
12 )
13 self.assertEqual(
14 "\П".encode("utf-8"),
15 b'\\\xd0\x9f'
16 )
17
18 def test_badsyntax(self):
19 try:
20 import test.badsyntax_pep3120
21 except SyntaxError as msg:
22 self.assert_(str(msg).find("Non-UTF-8 code starting with") >= 0)
23 else:
24 self.fail("expected exception didn't occur")
25
26def test_main():
27 test_support.run_unittest(PEP3120Test)
28
29if __name__=="__main__":
30 test_main()