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

Side by Side Diff: Lib/test/test_compileall.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months 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:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_codeop.py ('k') | Lib/test/test_compile.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 self.recreation_check(b'\0\0\0\0') 63 self.recreation_check(b'\0\0\0\0')
64 64
65 def test_compile_files(self): 65 def test_compile_files(self):
66 # Test compiling a single file, and complete directory 66 # Test compiling a single file, and complete directory
67 for fn in (self.bc_path, self.bc_path2): 67 for fn in (self.bc_path, self.bc_path2):
68 try: 68 try:
69 os.unlink(fn) 69 os.unlink(fn)
70 except: 70 except:
71 pass 71 pass
72 compileall.compile_file(self.source_path, force=False, quiet=True) 72 compileall.compile_file(self.source_path, force=False, quiet=True)
73 self.assertTrue(os.path.isfile(self.bc_path) and 73 self.assertTrue(os.path.isfile(self.bc_path))
74 not os.path.isfile(self.bc_path2)) 74 self.assertFalse(os.path.isfile(self.bc_path2))
75 os.unlink(self.bc_path) 75 os.unlink(self.bc_path)
76 compileall.compile_dir(self.directory, force=False, quiet=True) 76 compileall.compile_dir(self.directory, force=False, quiet=True)
77 self.assertTrue(os.path.isfile(self.bc_path) and 77 self.assertTrue(os.path.isfile(self.bc_path))
78 os.path.isfile(self.bc_path2)) 78 self.assertTrue(os.path.isfile(self.bc_path2))
79 os.unlink(self.bc_path) 79 os.unlink(self.bc_path)
80 os.unlink(self.bc_path2) 80 os.unlink(self.bc_path2)
81 81
82 def test_no_pycache_in_non_package(self): 82 def test_no_pycache_in_non_package(self):
83 # Bug 8563 reported that __pycache__ directories got created by 83 # Bug 8563 reported that __pycache__ directories got created by
84 # compile_file() for non-.py files. 84 # compile_file() for non-.py files.
85 data_dir = os.path.join(self.directory, 'data') 85 data_dir = os.path.join(self.directory, 'data')
86 data_file = os.path.join(data_dir, 'file') 86 data_file = os.path.join(data_dir, 'file')
87 os.mkdir(data_dir) 87 os.mkdir(data_dir)
88 # touch data/file 88 # touch data/file
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 self.assertCompiled(self.initfn) 375 self.assertCompiled(self.initfn)
376 self.assertCompiled(self.barfn) 376 self.assertCompiled(self.barfn)
377 377
378 def test_invalid_arg_produces_message(self): 378 def test_invalid_arg_produces_message(self):
379 out = self.assertRunOK('badfilename') 379 out = self.assertRunOK('badfilename')
380 self.assertRegex(out, b"Can't list 'badfilename'") 380 self.assertRegex(out, b"Can't list 'badfilename'")
381 381
382 382
383 if __name__ == "__main__": 383 if __name__ == "__main__":
384 unittest.main() 384 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_codeop.py ('k') | Lib/test/test_compile.py » ('j') | no next file with comments »

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