Index: Lib/test/test_compileall.py =================================================================== --- Lib/test/test_compileall.py (revisione 86582) +++ Lib/test/test_compileall.py (copia locale) @@ -184,7 +184,57 @@ self.assertTrue(os.path.exists(cachedir)) self.assertFalse(os.path.exists(cachecachedir)) + def test_force(self): + retcode = subprocess.call( + (sys.executable, '-m', 'compileall', self.pkgdir)) + self.assertEqual(retcode, 0) + access = os.stat(self.pkgdir).st_atime + retcode = subprocess.call( + (sys.executable, '-m', 'compileall', '-f', self.pkgdir)) + self.assertEqual(retcode, 0) + access2 = os.stat(self.pkgdir).st_atime + + self.assertNotEqual(access, access2) + + def test_legacy(self): + # create a new module + newpackage = os.path.join(self.pkgdir, 'spam') + os.mkdir(newpackage) + with open(os.path.join(newpackage, '__init__.py'), 'w'): + pass + with open(os.path.join(newpackage, 'ham.py'), 'w'): + pass + sourcefile = os.path.join(newpackage, 'ham.py') + + retcode = subprocess.call( + (sys.executable, '-m', 'compileall', '-l', self.pkgdir)) + self.assertEqual(retcode, 0) + self.assertFalse(os.path.exists(imp.cache_from_source(sourcefile))) + + retcode = subprocess.call( + (sys.executable, '-m', 'compileall', self.pkgdir)) + self.assertEqual(retcode, 0) + self.assertTrue(os.path.exists(imp.cache_from_source(sourcefile))) + + def test_quiet(self): + noise = subprocess.getoutput('{} -m compileall {}'.format( + sys.executable, self.pkgdir)) + quiet = subprocess.getoutput(('{} -m compileall {}'.format( + sys.executable, self.pkgdir))) + self.assertTrue(len(noise) > len(quiet)) + + def test_regexp(self): + retcode = subprocess.call( + (sys.executable, '-m', 'compileall', '-x', 'bar.*', self.pkgdir)) + self.assertEqual(retcode, 0) + + sourcefile = os.path.join(self.pkgdir, 'bar.py') + self.assertFalse(os.path.exists(imp.cache_from_source(sourcefile))) + sourcefile = os.path.join(self.pkgdir, '__init__.py') + self.assertTrue(os.path.exists(imp.cache_from_source(sourcefile))) + + def test_main(): support.run_unittest( CommandLineTests,