summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compileall.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-12-16 01:49:38 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-12-16 01:49:38 (GMT)
commit8a1d1e647eb133cb1687e183dc0aefa7e2f02fdb (patch)
tree7267be36dc61e06bd0817d559e0a753b3f25c58e /Lib/test/test_compileall.py
parent1f1ec12db9eefa36bc7a2227c40ecdfcac945439 (diff)
downloadcpython-8a1d1e647eb133cb1687e183dc0aefa7e2f02fdb.zip
cpython-8a1d1e647eb133cb1687e183dc0aefa7e2f02fdb.tar.gz
cpython-8a1d1e647eb133cb1687e183dc0aefa7e2f02fdb.tar.bz2
#19532: make compileall with no file/dir args respect -f and -q.
Patch by Vajrasky Kok.
Diffstat (limited to 'Lib/test/test_compileall.py')
-rw-r--r--Lib/test/test_compileall.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index fddb538..0505c52 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -177,6 +177,29 @@ class CommandLineTests(unittest.TestCase):
self.assertNotCompiled(self.initfn)
self.assertNotCompiled(self.barfn)
+ def test_no_args_respects_force_flag(self):
+ bazfn = script_helper.make_script(self.directory, 'baz', '')
+ self.assertRunOK(PYTHONPATH=self.directory)
+ pycpath = imp.cache_from_source(bazfn)
+ # Set atime/mtime backward to avoid file timestamp resolution issues
+ os.utime(pycpath, (time.time()-60,)*2)
+ mtime = os.stat(pycpath).st_mtime
+ # Without force, no recompilation
+ self.assertRunOK(PYTHONPATH=self.directory)
+ mtime2 = os.stat(pycpath).st_mtime
+ self.assertEqual(mtime, mtime2)
+ # Now force it.
+ self.assertRunOK('-f', PYTHONPATH=self.directory)
+ mtime2 = os.stat(pycpath).st_mtime
+ self.assertNotEqual(mtime, mtime2)
+
+ def test_no_args_respects_quiet_flag(self):
+ script_helper.make_script(self.directory, 'baz', '')
+ noisy = self.assertRunOK(PYTHONPATH=self.directory)
+ self.assertIn(b'Listing ', noisy)
+ quiet = self.assertRunOK('-q', PYTHONPATH=self.directory)
+ self.assertNotIn(b'Listing ', quiet)
+
# Ensure that the default behavior of compileall's CLI is to create
# PEP 3147 pyc/pyo files.
for name, ext, switch in [