diff options
author | Barry Warsaw <barry@python.org> | 2010-04-29 18:43:10 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2010-04-29 18:43:10 (GMT) |
commit | c8a99de7513abe90716750090658e7e910664822 (patch) | |
tree | c44c51f45370b224f570a8c856cfd9b4fa2b784b /Lib/test/test_compileall.py | |
parent | d5334e1fa3fbc17c01f580a6efc2817720c63476 (diff) | |
download | cpython-c8a99de7513abe90716750090658e7e910664822.zip cpython-c8a99de7513abe90716750090658e7e910664822.tar.gz cpython-c8a99de7513abe90716750090658e7e910664822.tar.bz2 |
Bug 8563 - compileall.compile_file() creates empty __pycache__ directories in
data directories where there is no source.
Fix by: Arfrever Frehtes Taifersar Arahesis (Arfrever)
Test by: Barry
Diffstat (limited to 'Lib/test/test_compileall.py')
-rw-r--r-- | Lib/test/test_compileall.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py index fe26026..4ad0061 100644 --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -75,6 +75,18 @@ class CompileallTests(unittest.TestCase): os.unlink(self.bc_path) os.unlink(self.bc_path2) + def test_no_pycache_in_non_package(self): + # Bug 8563 reported that __pycache__ directories got created by + # compile_file() for non-.py files. + data_dir = os.path.join(self.directory, 'data') + data_file = os.path.join(data_dir, 'file') + os.mkdir(data_dir) + # touch data/file + with open(data_file, 'w'): + pass + compileall.compile_file(data_file) + self.assertFalse(os.path.exists(os.path.join(data_dir, '__pycache__'))) + class EncodingTest(unittest.TestCase): """Issue 6716: compileall should escape source code when printing errors @@ -98,6 +110,7 @@ class EncodingTest(unittest.TestCase): finally: sys.stdout = orig_stdout + class CommandLineTests(unittest.TestCase): """Test some aspects of compileall's CLI.""" |