+++ /dev/null
-\r
-import test.test_support, unittest\r
-import os\r
-\r
-class CodingTest(unittest.TestCase):\r
- def test_bad_coding(self):\r
- module_name = 'bad_coding'\r
- self.verify_bad_module(module_name)\r
-\r
- def test_bad_coding2(self):\r
- module_name = 'bad_coding2'\r
- self.verify_bad_module(module_name)\r
-\r
- def verify_bad_module(self, module_name):\r
- self.assertRaises(SyntaxError, __import__, 'test.' + module_name)\r
-\r
- path = os.path.dirname(__file__)\r
- filename = os.path.join(path, module_name + '.py')\r
- with open(filename) as fp:\r
- text = fp.read()\r
- self.assertRaises(SyntaxError, compile, text, filename, 'exec')\r
-\r
- def test_error_from_string(self):\r
- # See http://bugs.python.org/issue6289\r
- input = u"# coding: ascii\n\N{SNOWMAN}".encode('utf-8')\r
- with self.assertRaises(SyntaxError) as c:\r
- compile(input, "<string>", "exec")\r
- expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \\r
- "ordinal not in range(128)"\r
- self.assertTrue(c.exception.args[0].startswith(expected))\r
-\r
-\r
-def test_main():\r
- test.test_support.run_unittest(CodingTest)\r
-\r
-if __name__ == "__main__":\r
- test_main()\r