OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import shutil | 7 import shutil |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 def OpenZipFile(self): | 75 def OpenZipFile(self): |
76 self.zipfile = zipfile.ZipFile(self.GetTempPath(self.zipname), 'r') | 76 self.zipfile = zipfile.ZipFile(self.GetTempPath(self.zipname), 'r') |
77 | 77 |
78 def CloseZipFile(self): | 78 def CloseZipFile(self): |
79 self.zipfile.close() | 79 self.zipfile.close() |
80 self.zipfile = None | 80 self.zipfile = None |
81 | 81 |
82 def GetZipInfo(self, path): | 82 def GetZipInfo(self, path): |
83 return self.zipfile.getinfo(oshelpers.OSMakeZipPath(path)) | 83 return self.zipfile.getinfo(oshelpers.OSMakeZipPath(path)) |
84 | 84 |
85 | |
86 def testNothingToDo(self): | 85 def testNothingToDo(self): |
87 self.assertRaises(subprocess.CalledProcessError, self.RunZip, | 86 self.assertRaises(subprocess.CalledProcessError, self.RunZip, |
88 self.zipname, 'nonexistent_file') | 87 self.zipname, 'nonexistent_file') |
89 self.assertFalse(os.path.exists(self.zipname)) | 88 self.assertFalse(os.path.exists(self.zipname)) |
90 | 89 |
91 def testAddSomeFiles(self): | 90 def testAddSomeFiles(self): |
92 file1 = self.MakeFile('file1', 1024) | 91 file1 = self.MakeFile('file1', 1024) |
93 file2 = self.MakeFile('file2', 3354) | 92 file2 = self.MakeFile('file2', 3354) |
94 self.RunZip(self.zipname, file1, file2) | 93 self.RunZip(self.zipname, file1, file2) |
95 self.OpenZipFile() | 94 self.OpenZipFile() |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 bin_cp = self.MakeExecutableFile('bin', 'cp') | 247 bin_cp = self.MakeExecutableFile('bin', 'cp') |
249 cp = os.path.basename(bin_cp) | 248 cp = os.path.basename(bin_cp) |
250 | 249 |
251 # Note, "bin" not added to PATH. | 250 # Note, "bin" not added to PATH. |
252 output, _ = self.RunWhich(bin_cp) | 251 output, _ = self.RunWhich(bin_cp) |
253 self.assertTrue(os.path.join('bin', cp) in output) | 252 self.assertTrue(os.path.join('bin', cp) in output) |
254 | 253 |
255 | 254 |
256 if __name__ == '__main__': | 255 if __name__ == '__main__': |
257 unittest.main() | 256 unittest.main() |
OLD | NEW |