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

Unified Diff: chrome/test/functional/downloads.py

Issue 3141039: Cleanup in downloads tests (Closed)
Patch Set: . Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/pyautolib/pyauto_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/downloads.py
diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py
index f998b3654e009d119472d9c94f32483b5d294a20..2d41f5d40418a45e6dbb61f88ed1197c66e6eb8f 100644
--- a/chrome/test/functional/downloads.py
+++ b/chrome/test/functional/downloads.py
@@ -14,11 +14,29 @@ import urllib
import pyauto_functional # Must be imported before pyauto
import pyauto
+import pyauto_utils
class DownloadsTest(pyauto.PyUITest):
"""TestCase for Downloads."""
+ def setUp(self):
+ pyauto.PyUITest.setUp(self)
+ # Record all entries in the download dir
+ download_dir = self.GetDownloadDirectory().value()
+ self._existing_downloads = []
+ if os.path.isdir(download_dir):
+ self._existing_downloads += os.listdir(download_dir)
+
+ def tearDown(self):
+ # Cleanup all files we created in the download dir
+ download_dir = self.GetDownloadDirectory().value()
+ if os.path.isdir(download_dir):
+ for name in os.listdir(download_dir):
+ if name not in self._existing_downloads:
+ pyauto_utils.RemovePath(os.path.join(download_dir, name))
+ pyauto.PyUITest.tearDown(self)
+
def _GetDangerousDownload(self):
"""Returns the file url for a dangerous download for this OS."""
sub_path = os.path.join(self.DataDir(), 'downloads', 'dangerous')
@@ -245,6 +263,7 @@ class DownloadsTest(pyauto.PyUITest):
self.assertEqual(1, len(downloads))
self.assertEqual('a_zip_file.zip', downloads[0]['file_name'])
self.assertEqual(file_url, downloads[0]['url'])
+ os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
if __name__ == '__main__':
« no previous file with comments | « no previous file | chrome/test/pyautolib/pyauto_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698