Merge lp:~elachuni/software-center/test_downloader_fix into lp:software-center
Status: | Merged |
---|---|
Merged at revision: | 2656 |
Proposed branch: | lp:~elachuni/software-center/test_downloader_fix |
Merge into: | lp:software-center |
Diff against target: |
13 lines (+2/-1) 1 file modified
test/test_downloader.py (+2/-1) |
To merge this branch: | bzr merge lp:~elachuni/software-center/test_downloader_fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
software-store-developers | Pending | ||
Review via email: mp+88706@code.launchpad.net |
Description of the change
Overview
========
A really small fix to avoid a test hanging when your proxy settings are funny.
Details
=======
I found test_downloader.py hanging locally. Looking a bit closer, it was because my system proxy settings are set to "Manual", but with a blank hostname. This is apparently different to setting your proxy to "None".
test_downloader.py doesn't call utils.get_
So, for the moment, I've just changed the test so that it doesn't hang (although it'll still fail if you've got your system-wide proxy set to Manual with a blank host).
Hey Anthony!
Thanks a bunch for your branch and the fix! I merged it, but tweaks it a little bit because in complete call is done and thus the
download_file() there is always a "is-reachable" check before so if the loop has odd timing the
reachable state can change to true before the file-download-
test would fail. I added a proper check for the "error" signal now. The test will still fail
when there is no network, but that is ok I think (for now):
=== modified file 'test/test_ downloader. py' downloader. py 2012-01-16 14:42:49 +0000 downloader. py 2012-01-17 08:36:04 +0000
self. _cb_image_ url_reachable)
self. downloader. connect( "file-download- complete" ,
self. _cb_image_ download_ complete) .connect( "error" , image_download_ error)
self. _image_ is_reachable = None
self. _image_ downloaded_ filename = None exists( self.DOWNLOAD_ FILENAME) :
os. unlink( self.DOWNLOAD_ FILENAME)
--- test/test_
+++ test/test_
@@ -20,8 +20,11 @@
+ self.downloader
+ self._cb_
+ self._error = False
if os.path.
@@ -31,6 +34,9 @@ download_ complete( self, downloader, filename):
self. _image_ downloaded_ filename = filename
def _cb_image_
+ def _cb_image_ download_ error(self, downloader, gerror, exc): unreachable( self):
self. downloader. download_ file("http:// www.ubuntu. com/really- not-there",
self. DOWNLOAD_ FILENAME)
self. downloader. download_ file("http:// www.ubuntu. com",
self. DOWNLOAD_ FILENAME) main_context_ default( ) downloaded_ filename is None: image_downloade d_filename is None and pending( ):
main_ loop.iteration( )
time. sleep(0. 1)
+ self._error = True
+
def test_download_
@@ -47,7 +53,8 @@
main_loop = GObject.
- while self._image_
+ while (self._
+ not self._error):
while main_loop.