Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13901)

Delta Between Two Patch Sets: Lib/test/test_compileall.py

Issue 16104: Use multiprocessing in compileall script
Left Patch Set: Created 5 years, 4 months ago
Right Patch Set: Created 5 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« Lib/compileall.py ('K') | « Lib/compileall.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import sys 1 import sys
2 import compileall 2 import compileall
3 import importlib.util 3 import importlib.util
4 import os 4 import os
5 import py_compile 5 import py_compile
6 import shutil 6 import shutil
7 import struct 7 import struct
8 import tempfile 8 import tempfile
9 import time 9 import time
10 import unittest 10 import unittest
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 os.mkdir(subpackage) 301 os.mkdir(subpackage)
302 subinitfn = script_helper.make_script(subpackage, '__init__', '') 302 subinitfn = script_helper.make_script(subpackage, '__init__', '')
303 hamfn = script_helper.make_script(subpackage, 'ham', '') 303 hamfn = script_helper.make_script(subpackage, 'ham', '')
304 self.assertRunOK('-q', '-l', self.pkgdir) 304 self.assertRunOK('-q', '-l', self.pkgdir)
305 self.assertNotCompiled(subinitfn) 305 self.assertNotCompiled(subinitfn)
306 self.assertFalse(os.path.exists(os.path.join(subpackage, '__pycache__')) ) 306 self.assertFalse(os.path.exists(os.path.join(subpackage, '__pycache__')) )
307 self.assertRunOK('-q', self.pkgdir) 307 self.assertRunOK('-q', self.pkgdir)
308 self.assertCompiled(subinitfn) 308 self.assertCompiled(subinitfn)
309 self.assertCompiled(hamfn) 309 self.assertCompiled(hamfn)
310 310
311 def test_recursion_limit(self):
312 subpackage = os.path.join(self.pkgdir, 'spam')
313 subpackage2 = os.path.join(subpackage, 'ham')
314 subpackage3 = os.path.join(subpackage2, 'eggs')
315 for pkg in (subpackage, subpackage2, subpackage3):
316 script_helper.make_pkg(pkg)
317
318 subinitfn = os.path.join(subpackage, '__init__.py')
319 hamfn = script_helper.make_script(subpackage, 'ham', '')
320 spamfn = script_helper.make_script(subpackage2, 'spam', '')
321 eggfn = script_helper.make_script(subpackage3, 'egg', '')
322
323 self.assertRunOK('-q', '-r 0', self.pkgdir)
324 self.assertNotCompiled(subinitfn)
325 self.assertFalse(
326 os.path.exists(os.path.join(subpackage, '__pycache__')))
327
328 self.assertRunOK('-q', '-r 1', self.pkgdir)
329 self.assertCompiled(subinitfn)
330 self.assertCompiled(hamfn)
331 self.assertNotCompiled(spamfn)
332
333 self.assertRunOK('-q', '-r 2', self.pkgdir)
334 self.assertCompiled(subinitfn)
335 self.assertCompiled(hamfn)
336 self.assertCompiled(spamfn)
337 self.assertNotCompiled(eggfn)
338
339 self.assertRunOK('-q', '-r 5', self.pkgdir)
340 self.assertCompiled(subinitfn)
341 self.assertCompiled(hamfn)
342 self.assertCompiled(spamfn)
343 self.assertCompiled(eggfn)
344
311 def test_quiet(self): 345 def test_quiet(self):
312 noisy = self.assertRunOK(self.pkgdir) 346 noisy = self.assertRunOK(self.pkgdir)
313 quiet = self.assertRunOK('-q', self.pkgdir) 347 quiet = self.assertRunOK('-q', self.pkgdir)
314 self.assertNotEqual(b'', noisy) 348 self.assertNotEqual(b'', noisy)
315 self.assertEqual(b'', quiet) 349 self.assertEqual(b'', quiet)
316 350
317 def test_regexp(self): 351 def test_regexp(self):
318 self.assertRunOK('-q', '-x', r'ba[^\\/]*$', self.pkgdir) 352 self.assertRunOK('-q', '-x', r'ba[^\\/]*$', self.pkgdir)
319 self.assertNotCompiled(self.barfn) 353 self.assertNotCompiled(self.barfn)
320 self.assertCompiled(self.initfn) 354 self.assertCompiled(self.initfn)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 with mock.patch("sys.argv", 468 with mock.patch("sys.argv",
435 new=[sys.executable, self.directory, "-j0"]): 469 new=[sys.executable, self.directory, "-j0"]):
436 compileall.main() 470 compileall.main()
437 self.assertTrue(compile_dir.called) 471 self.assertTrue(compile_dir.called)
438 self.assertEqual(compile_dir.call_args[-1]['workers'], 472 self.assertEqual(compile_dir.call_args[-1]['workers'],
439 os.cpu_count()) 473 os.cpu_count())
440 474
441 475
442 if __name__ == "__main__": 476 if __name__ == "__main__":
443 unittest.main() 477 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+