You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/08/26 22:34:48 UTC

git commit: [#6531] Fixed failing tests from previous commit

Updated Branches:
  refs/heads/master 8c6605d3f -> b1e19c8b1


[#6531] Fixed failing tests from previous commit

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b1e19c8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b1e19c8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b1e19c8b

Branch: refs/heads/master
Commit: b1e19c8b1eeb885c2287403dae96a0a5c3b97475
Parents: 8c6605d
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Aug 26 20:34:06 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Mon Aug 26 20:34:06 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/helpers.py        | 2 +-
 Allura/allura/tests/test_helpers.py | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b1e19c8b/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index e545289..b7b0060 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -947,9 +947,9 @@ def urlopen(url, retries=3, codes=(408,), timeout=None):
         try:
             return urllib2.urlopen(url, timeout=timeout)
         except (urllib2.HTTPError, socket.timeout) as e:
-            attempts += 1
             if attempts < retries and (isinstance(e, socket.timeout) or
                     e.code in codes):
+                attempts += 1
                 continue
             else:
                 try:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b1e19c8b/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 4a0b80d..3c79e61 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -354,12 +354,12 @@ class TestUrlOpen(TestCase):
     def test_no_error(self, urllib2):
         r = h.urlopen('myurl')
         self.assertEqual(r, urllib2.urlopen.return_value)
-        urllib2.urlopen.assert_called_once_with('myurl')
+        urllib2.urlopen.assert_called_once_with('myurl', timeout=None)
 
     @patch('allura.lib.helpers.urllib2.urlopen')
     def test_socket_timeout(self, urlopen):
         import socket
-        def side_effect(url):
+        def side_effect(url, timeout=None):
             raise socket.timeout()
         urlopen.side_effect = side_effect
         self.assertRaises(socket.timeout, h.urlopen, 'myurl')
@@ -368,7 +368,7 @@ class TestUrlOpen(TestCase):
     @patch('allura.lib.helpers.urllib2.urlopen')
     def test_handled_http_error(self, urlopen):
         from urllib2 import HTTPError
-        def side_effect(url):
+        def side_effect(url, timeout=None):
             raise HTTPError('url', 408, 'timeout', None, None)
         urlopen.side_effect = side_effect
         self.assertRaises(HTTPError, h.urlopen, 'myurl')
@@ -377,7 +377,7 @@ class TestUrlOpen(TestCase):
     @patch('allura.lib.helpers.urllib2.urlopen')
     def test_unhandled_http_error(self, urlopen):
         from urllib2 import HTTPError
-        def side_effect(url):
+        def side_effect(url, timeout=None):
             raise HTTPError('url', 404, 'timeout', None, None)
         urlopen.side_effect = side_effect
         self.assertRaises(HTTPError, h.urlopen, 'myurl')