annotate Lib/test/test_coding.py @ 39042:c02fa187e0f4 legacy-trunk

Part of SF patch #1484695. This removes dead code. The chksum was already verified in .frombuf() on the lines above. If there was a problem an exception is raised, so there was no way this condition could have been true.
author Neal Norwitz <nnorwitz@gmail.com>
date Mon, 10 Jul 2006 00:23:17 +0000
parents 1ff4790b7605
children 4a50f0bdc806 e0f62286a9a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35666
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
1
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
2 import test.test_support, unittest
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
3 import os
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
4
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
5 class CodingTest(unittest.TestCase):
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
6 def test_bad_coding(self):
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
7 module_name = 'bad_coding'
36078
1ff4790b7605 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35666
diff changeset
8 self.verify_bad_module(module_name)
1ff4790b7605 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35666
diff changeset
9
1ff4790b7605 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35666
diff changeset
10 def test_bad_coding2(self):
1ff4790b7605 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35666
diff changeset
11 module_name = 'bad_coding2'
1ff4790b7605 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35666
diff changeset
12 self.verify_bad_module(module_name)
1ff4790b7605 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35666
diff changeset
13
1ff4790b7605 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35666
diff changeset
14 def verify_bad_module(self, module_name):
35666
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
15 self.assertRaises(SyntaxError, __import__, 'test.' + module_name)
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
16
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
17 path = os.path.dirname(__file__)
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
18 filename = os.path.join(path, module_name + '.py')
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
19 fp = open(filename)
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
20 text = fp.read()
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
21 fp.close()
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
22 self.assertRaises(SyntaxError, compile, text, filename, 'exec')
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
23
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
24 def test_main():
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
25 test.test_support.run_unittest(CodingTest)
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
26
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
27 if __name__ == "__main__":
b8e571e6de2e - Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
28 test_main()