diff options
author | Georg Brandl <georg@python.org> | 2010-12-04 10:26:46 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-12-04 10:26:46 +0000 |
commit | 8334fd9285a8e9f0864b0453ae738fe3f6893b21 (patch) | |
tree | f9341847b4647cd85b6fcd4e5fbece5cd15e1883 /Lib/test/test_zipfile.py | |
parent | 427d3149ebe5c4495e69a04be5464e5b8b446c9e (diff) | |
download | cpython-git-8334fd9285a8e9f0864b0453ae738fe3f6893b21.tar.gz |
Add an "optimize" parameter to compile() to control the optimization level, and provide an interface to it in py_compile, compileall and PyZipFile.
Diffstat (limited to 'Lib/test/test_zipfile.py')
-rw-r--r-- | Lib/test/test_zipfile.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 7f93b68e27..a0367e188d 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -654,6 +654,22 @@ class PyZipFileTests(unittest.TestCase): self.assertTrue('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names) + def test_write_with_optimization(self): + import email + packagedir = os.path.dirname(email.__file__) + # use .pyc if running test in optimization mode, + # use .pyo if running test in debug mode + optlevel = 1 if __debug__ else 0 + ext = '.pyo' if optlevel == 1 else '.pyc' + + with TemporaryFile() as t, \ + zipfile.PyZipFile(t, "w", optimize=optlevel) as zipfp: + zipfp.writepy(packagedir) + + names = zipfp.namelist() + self.assertIn('email/__init__' + ext, names) + self.assertIn('email/mime/text' + ext, names) + def test_write_python_directory(self): os.mkdir(TESTFN2) try: |