From 8384b0f754ce76be1a670eb5467b68cb5842eb4b Mon Sep 17 00:00:00 2001 From: "kkania@chromium.org" Date: Wed, 5 Oct 2011 18:36:49 +0000 Subject: Fix pyauto import tests with python2.6 on mac. BUG=none TEST=none TBR=dennisjeffrey Review URL: http://codereview.chromium.org/8135035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104139 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/functional/imports.py | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'chrome/test/functional/imports.py') diff --git a/chrome/test/functional/imports.py b/chrome/test/functional/imports.py index 9ba8d3d..197a5ba 100644 --- a/chrome/test/functional/imports.py +++ b/chrome/test/functional/imports.py @@ -84,30 +84,17 @@ class ImportsTest(pyauto.PyUITest): Creates |dir| if it doesn't exist. """ + if not os.path.isdir(dir): + os.makedirs(dir) zf = zipfile.ZipFile(profile_zip) - # Make base. - pushd = os.getcwd() - try: - if not os.path.isdir(dir): - os.mkdir(dir) - os.chdir(dir) - # Extract files. - for info in zf.infolist(): - name = info.filename - if name.endswith('/'): # It's a directory. - if not os.path.isdir(name): - os.makedirs(name) - else: # It's a file. - dir = os.path.dirname(name) - if dir and not os.path.isdir(dir): - os.makedirs(dir) - out = open(name, 'wb') - out.write(zf.read(name)) - out.close() - # Set permissions. - os.chmod(name, 0777) - finally: - os.chdir(pushd) + for name in zf.namelist(): + full_path = os.path.join(dir, name) + if name.endswith('/'): + if not os.path.isdir(full_path): + os.makedirs(full_path) + else: + zf.extract(name, dir) + os.chmod(full_path, 0777) def _SwapFirefoxProfile(self): """Swaps the test Firefox profile with the original one.""" -- cgit v1.1