Raymond Hettinger | f9f4c69 | 2003-08-30 22:54:55 +0000 | [diff] [blame] | 1 | #! -*- coding: koi8-r -*-
|
Georg Brandl | 38d1715 | 2008-01-21 18:35:49 +0000 | [diff] [blame] | 2 | # This file is marked as binary in SVN, to prevent MacCVS from recoding it.
|
Raymond Hettinger | f9f4c69 | 2003-08-30 22:54:55 +0000 | [diff] [blame] | 3 |
|
| 4 | import unittest
|
| 5 | from test import test_support
|
| 6 |
|
| 7 | class PEP263Test(unittest.TestCase):
|
| 8 |
|
| 9 | def test_pep263(self):
|
| 10 | self.assertEqual(
|
| 11 | u"ðÉÔÏÎ".encode("utf-8"),
|
| 12 | '\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd'
|
| 13 | )
|
| 14 | self.assertEqual(
|
| 15 | u"\ð".encode("utf-8"),
|
| 16 | '\\\xd0\x9f'
|
| 17 | )
|
| 18 |
|
Georg Brandl | 38d1715 | 2008-01-21 18:35:49 +0000 | [diff] [blame] | 19 | def test_compilestring(self):
|
| 20 | # see #1882
|
| 21 | c = compile("\n# coding: utf-8\nu = u'\xc3\xb3'\n", "dummy", "exec")
|
| 22 | d = {}
|
| 23 | exec c in d
|
| 24 | self.assertEqual(d['u'], u'\xf3')
|
| 25 |
|
| 26 |
|
Raymond Hettinger | f9f4c69 | 2003-08-30 22:54:55 +0000 | [diff] [blame] | 27 | def test_main():
|
| 28 | test_support.run_unittest(PEP263Test)
|
| 29 |
|
| 30 | if __name__=="__main__":
|
| 31 | test_main()
|