Merge lp:~dobey/software-center/bad-tests into lp:software-center

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 3311
Merged at revision: 3311
Proposed branch: lp:~dobey/software-center/bad-tests
Merge into: lp:software-center
Diff against target: 109 lines (+4/-90)
2 files modified
tests/test_downloader.py (+0/-89)
tests/test_pyflakes.py (+4/-1)
To merge this branch: bzr merge lp:~dobey/software-center/bad-tests
Reviewer Review Type Date Requested Status
Roberto Alsina Approve
Review via email: mp+175291@code.launchpad.net

Commit message

Remove bad tests that depend on network.
Fix pyflakes to only run on certain subdirs, and not everything in cwd.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'tests/test_downloader.py'
2--- tests/test_downloader.py 2012-09-26 07:36:55 +0000
3+++ tests/test_downloader.py 1970-01-01 00:00:00 +0000
4@@ -1,89 +0,0 @@
5-import glob
6-import os
7-import tempfile
8-import unittest
9-
10-from tests.utils import (
11- do_events_with_sleep,
12- setup_test_env,
13-)
14-setup_test_env()
15-from softwarecenter.utils import SimpleFileDownloader
16-
17-
18-class TestImageDownloader(unittest.TestCase):
19-
20- DOWNLOAD_FILENAME = "test_image_download"
21-
22- def setUp(self):
23- self.downloader = SimpleFileDownloader()
24- self.downloader.connect("file-url-reachable",
25- self._cb_image_url_reachable)
26- self.downloader.connect("file-download-complete",
27- self._cb_image_download_complete)
28- self.downloader.connect("error",
29- self._cb_image_download_error)
30- self._image_is_reachable = None
31- self._image_downloaded_filename = None
32- self._error = False
33- if os.path.exists(self.DOWNLOAD_FILENAME):
34- os.unlink(self.DOWNLOAD_FILENAME)
35-
36- def _cb_image_url_reachable(self, downloader, is_reachable):
37- self._image_is_reachable = is_reachable
38-
39- def _cb_image_download_complete(self, downloader, filename):
40- self._image_downloaded_filename = filename
41-
42- def _cb_image_download_error(self, downloader, gerror, exc):
43- print "ERROR '%s'" % exc
44- self._error = True
45-
46- @unittest.skipIf(not "DBUS_SESSION_BUS_ADDRESS" in os.environ,
47- "Need dbus session bus for the gio based test")
48- def test_download_unreachable(self):
49- self.downloader.download_file("http://www.ubuntu.com/really-not-there",
50- self.DOWNLOAD_FILENAME)
51- while self._image_is_reachable is None:
52- do_events_with_sleep()
53- self.assertNotEqual(self._image_is_reachable, None)
54- self.assertFalse(self._image_is_reachable)
55- self.assertTrue(not os.path.exists(self.DOWNLOAD_FILENAME))
56-
57- @unittest.skipIf(not "DBUS_SESSION_BUS_ADDRESS" in os.environ,
58- "Need dbus session bus for the gio based test")
59- def test_download_reachable(self):
60- self.downloader.download_file("http://www.google.com",
61- self.DOWNLOAD_FILENAME)
62- while (self._image_downloaded_filename is None and
63- not self._error):
64- do_events_with_sleep()
65- self.assertNotEqual(self._image_is_reachable, None)
66- self.assertTrue(self._image_is_reachable)
67- self.assertTrue(os.path.exists(self.DOWNLOAD_FILENAME))
68-
69- @unittest.skip("highly dependant on network speed so disabled by default")
70- def test_download_race_lp839462(self):
71- hosts = ["google", "ubuntu"]
72- tmpdir = tempfile.mkdtemp()
73- # mvo: in order to reproduce the race these paramters can be tweaked
74- # its highly depedant on network latency, for me it hit 1/3 times
75- # at around i=7,8 - if the race ever hits again this will be a useful
76- # starting point
77- for i in range(5,15):
78- for host in hosts:
79- url = "http://www.%s.com/" % host
80- target = os.path.join(tmpdir, host)
81- self.downloader.download_file(url, target)
82- do_events_with_sleep(iterations=i)
83- for host in hosts:
84- downloaded_file = os.path.join(tmpdir, host)
85- if os.path.exists(downloaded_file):
86- self.assertTrue(
87- host in open(downloaded_file).read().lower(),
88- "file '%s' contains wrong content" % downloaded_file)
89- for f in glob.glob(tmpdir+"/*"):
90- os.unlink(f)
91-
92-if __name__ == "__main__":
93- unittest.main()
94
95=== modified file 'tests/test_pyflakes.py'
96--- tests/test_pyflakes.py 2012-05-30 18:39:55 +0000
97+++ tests/test_pyflakes.py 2013-07-17 14:11:26 +0000
98@@ -5,7 +5,10 @@
99 """ ensure that the tree is pyflakes clean """
100
101 def test_pyflakes_clean(self):
102- self.assertEqual(subprocess.call(["pyflakes", "."]), 0)
103+ self.assertEqual(subprocess.call(
104+ ["pyflakes", "bin", "contrib", "softwarecenter",
105+ "tests", "utils"]),
106+ 0)
107
108
109 if __name__ == "__main__":

Subscribers

People subscribed via source and target branches