diff options
author | Brett Cannon <brett@python.org> | 2013-04-14 12:48:15 -0400 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-04-14 12:48:15 -0400 |
commit | edfd6ae79c76ebf766ffc1da1e8003ab72df6475 (patch) | |
tree | 7c7387f82f4e909e0a96b3e6a82d7f7e3e475156 /Lib/test/test_py_compile.py | |
parent | 672559fc4f6d3811440965a12d900209f364b5f0 (diff) | |
download | cpython-git-edfd6ae79c76ebf766ffc1da1e8003ab72df6475.tar.gz |
Issue #17244: Don't mask exceptions raised during the creation of
bytecode files in py_compile.
Thanks to Arfrever Frehtes Taifersar Arahesis for the bug report.
Diffstat (limited to 'Lib/test/test_py_compile.py')
-rw-r--r-- | Lib/test/test_py_compile.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index f3c1a6a44b..13947b1634 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -2,6 +2,7 @@ import imp import os import py_compile import shutil +import stat import tempfile import unittest @@ -54,8 +55,18 @@ class PyCompileTests(unittest.TestCase): self.assertTrue(os.path.exists(self.pyc_path)) self.assertFalse(os.path.exists(self.cache_path)) -def test_main(): - support.run_unittest(PyCompileTests) + def test_exceptions_propagate(self): + # Make sure that exceptions raised thanks to issues with writing + # bytecode. + # http://bugs.python.org/issue17244 + mode = os.stat(self.directory) + os.chmod(self.directory, stat.S_IREAD) + try: + with self.assertRaises(IOError): + py_compile.compile(self.source_path, self.pyc_path) + finally: + os.chmod(self.directory, mode.st_mode) + if __name__ == "__main__": - test_main() + unittest.main()
\ No newline at end of file |