mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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__). ........
This commit is contained in:
parent
82f60910b7
commit
c33b902ebb
3 changed files with 123 additions and 50 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue