Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: dependency_manager/dependency_manager/dependency_manager_util_unittest.py

Issue 3004533002: [catapult] Roll forward Chrome reference builds (Closed)
Patch Set: skip test Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import shutil 6 import shutil
7 import stat 7 import stat
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 import unittest 10 import unittest
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 except: 157 except:
158 if os.path.isfile(archive_path): 158 if os.path.isfile(archive_path):
159 os.remove(archive_path) 159 os.remove(archive_path)
160 raise 160 raise
161 161
162 unzip_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4())) 162 unzip_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
163 dependency_manager_util.UnzipArchive(archive_path, unzip_path) 163 dependency_manager_util.UnzipArchive(archive_path, unzip_path)
164 dependency_manager_util.RemoveDir(unzip_path) 164 dependency_manager_util.RemoveDir(unzip_path)
165 165
166 def testUnzipFileFailure(self): 166 def testUnzipFileFailure(self):
167 # zipfile is not used on MacOS. See crbug.com/700097.
168 if sys.platform.startswith('darwin'):
169 return
167 unzip_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4())) 170 unzip_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
168 self.assertFalse(os.path.exists(unzip_path)) 171 self.assertFalse(os.path.exists(unzip_path))
169 with mock.patch( 172 with mock.patch(
170 'dependency_manager.dependency_manager_util.zipfile.ZipFile.extractall' # pylint: disable=line-too-long 173 'dependency_manager.dependency_manager_util.zipfile.ZipFile.extractall' # pylint: disable=line-too-long
171 ) as zipfile_mock: 174 ) as zipfile_mock:
172 zipfile_mock.side_effect = IOError 175 zipfile_mock.side_effect = IOError
173 self.assertRaises( 176 self.assertRaises(
174 IOError, dependency_manager_util.UnzipArchive, self.archive_path, 177 IOError, dependency_manager_util.UnzipArchive, self.archive_path,
175 unzip_path) 178 unzip_path)
176 self.AssertExpectedDirFiles(self.tmp_dir) 179 self.AssertExpectedDirFiles(self.tmp_dir)
177 self.assertFalse(os.path.exists(unzip_path)) 180 self.assertFalse(os.path.exists(unzip_path))
178 181
179 def testVerifySafeArchivePasses(self): 182 def testVerifySafeArchivePasses(self):
180 with zipfile.ZipFile(self.archive_path) as archive: 183 with zipfile.ZipFile(self.archive_path) as archive:
181 dependency_manager_util.VerifySafeArchive(archive) 184 dependency_manager_util.VerifySafeArchive(archive)
182 185
183 def testVerifySafeArchiveFailsOnRelativePathWithPardir(self): 186 def testVerifySafeArchiveFailsOnRelativePathWithPardir(self):
184 tmp_file = tempfile.NamedTemporaryFile(delete=False) 187 tmp_file = tempfile.NamedTemporaryFile(delete=False)
185 tmp_file_name = tmp_file.name 188 tmp_file_name = tmp_file.name
186 tmp_file.write('Bad file!') 189 tmp_file.write('Bad file!')
187 tmp_file.close() 190 tmp_file.close()
188 with zipfile.ZipFile(self.archive_path, 'w') as archive: 191 with zipfile.ZipFile(self.archive_path, 'w') as archive:
189 archive.write(tmp_file_name, '../../foo') 192 archive.write(tmp_file_name, '../../foo')
190 self.assertRaises( 193 self.assertRaises(
191 exceptions.ArchiveError, dependency_manager_util.VerifySafeArchive, 194 exceptions.ArchiveError, dependency_manager_util.VerifySafeArchive,
192 archive) 195 archive)
193 196
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698