1 # -*- coding: koi8-r -*-
4 from test
import test_support
6 class PEP263Test(unittest
.TestCase
):
10 u
"ðÉÔÏÎ".encode("utf-8"),
11 '\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd'
14 u
"\ð".encode("utf-8"),
18 def test_compilestring(self
):
20 c
= compile("\n# coding: utf-8\nu = u'\xc3\xb3'\n", "dummy", "exec")
23 self
.assertEqual(d
['u'], u
'\xf3')
26 def test_issue3297(self
):
27 c
= compile("a, b = '\U0001010F', '\\U0001010F'", "dummy", "exec")
30 self
.assertEqual(d
['a'], d
['b'])
31 self
.assertEqual(len(d
['a']), len(d
['b']))
33 def test_issue7820(self
):
34 # Ensure that check_bom() restores all bytes in the right order if
35 # check_bom() fails in pydebug mode: a buffer starts with the first
36 # byte of a valid BOM, but next bytes are different
38 # one byte in common with the UTF-16-LE BOM
39 self
.assertRaises(SyntaxError, eval, '\xff\x20')
41 # two bytes in common with the UTF-8 BOM
42 self
.assertRaises(SyntaxError, eval, '\xef\xbb\x20')
45 test_support
.run_unittest(PEP263Test
)
47 if __name__
=="__main__":