mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Add an "optimize" parameter to compile() to control the optimization level, and provide an interface to it in py_compile, compileall and PyZipFile.
This commit is contained in:
parent
427d3149eb
commit
8334fd9285
17 changed files with 280 additions and 97 deletions
|
@ -88,6 +88,15 @@ class CompileallTests(unittest.TestCase):
|
|||
compileall.compile_file(data_file)
|
||||
self.assertFalse(os.path.exists(os.path.join(data_dir, '__pycache__')))
|
||||
|
||||
def test_optimize(self):
|
||||
# make sure compiling with different optimization settings than the
|
||||
# interpreter's creates the correct file names
|
||||
optimize = 1 if __debug__ else 0
|
||||
compileall.compile_dir(self.directory, quiet=True, optimize=optimize)
|
||||
cached = imp.cache_from_source(self.source_path,
|
||||
debug_override=not optimize)
|
||||
self.assertTrue(os.path.isfile(cached))
|
||||
|
||||
|
||||
class EncodingTest(unittest.TestCase):
|
||||
"""Issue 6716: compileall should escape source code when printing errors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue