diff options
author | Matthias Klose <doko@ubuntu.com> | 2010-03-16 00:36:26 (GMT) |
---|---|---|
committer | Matthias Klose <doko@ubuntu.com> | 2010-03-16 00:36:26 (GMT) |
commit | c33b902ebb0e124061ed3213409dc37cffebced0 (patch) | |
tree | 9826b9ef24bd55bfbbaf44f204bc04a1fc9eca56 /Lib/test | |
parent | 82f60910b7b811555dd9a9cc520523dad212946a (diff) | |
download | cpython-c33b902ebb0e124061ed3213409dc37cffebced0.zip cpython-c33b902ebb0e124061ed3213409dc37cffebced0.tar.gz cpython-c33b902ebb0e124061ed3213409dc37cffebced0.tar.bz2 |
Merged revisions 78983,78985 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78983 | matthias.klose | 2010-03-15 18:44:12 +0100 (Mo, 15 Mär 2010) | 2 lines
- Issue #8140: extend compileall to compile single files. Add -i option.
........
r78985 | matthias.klose | 2010-03-15 19:00:01 +0100 (Mo, 15 Mär 2010) | 2 lines
- Fix typo in Lib/compileall.py(__all__).
........
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_compileall.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py index 1a71c5c..65622f7 100644 --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -17,6 +17,9 @@ class CompileallTests(unittest.TestCase): self.bc_path = self.source_path + ('c' if __debug__ else 'o') with open(self.source_path, 'w') as file: file.write('x = 123\n') + self.source_path2 = os.path.join(self.directory, '_test2.py') + self.bc_path2 = self.source_path2 + ('c' if __debug__ else 'o') + shutil.copyfile(self.source_path, self.source_path2) def tearDown(self): shutil.rmtree(self.directory) @@ -52,6 +55,22 @@ class CompileallTests(unittest.TestCase): # Test a change in mtime leads to a new .pyc. self.recreation_check(b'\0\0\0\0') + def test_compile_files(self): + # Test compiling a single file, and complete directory + for fn in (self.bc_path, self.bc_path2): + try: + os.unlink(fn) + except: + pass + compileall.compile_file(self.source_path, force=False, quiet=True) + self.assertTrue(os.path.isfile(self.bc_path) \ + and not os.path.isfile(self.bc_path2)) + os.unlink(self.bc_path) + compileall.compile_dir(self.directory, force=False, quiet=True) + self.assertTrue(os.path.isfile(self.bc_path) \ + and os.path.isfile(self.bc_path2)) + os.unlink(self.bc_path) + os.unlink(self.bc_path2) def test_main(): support.run_unittest(CompileallTests) |