jenkins-bot has submitted this change and it was merged.
Change subject: Fix threadedhttp imports ......................................................................
Fix threadedhttp imports
urlparse module was being imported on python 2 instead of the function. urljoin was being imported from httplib2 instead of the core libraries.
Also add test for HTTP 504
Change-Id: Iff85deef564d539b55af3bed5183fd0f090f81e0 --- M pywikibot/comms/threadedhttp.py M tests/http_tests.py 2 files changed, 9 insertions(+), 3 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py index b0369df..af9ce82 100644 --- a/pywikibot/comms/threadedhttp.py +++ b/pywikibot/comms/threadedhttp.py @@ -27,11 +27,11 @@
if sys.version_info[0] > 2: from http import cookiejar as cookielib - from urllib.parse import splittype, splithost, unquote, urlparse + from urllib.parse import splittype, splithost, unquote, urlparse, urljoin unicode = str else: import cookielib - import urlparse + from urlparse import urlparse, urljoin from urllib import splittype, splithost, unquote
import pywikibot @@ -277,7 +277,7 @@ (scheme, authority, path, query, fragment) = httplib2.parse_uri(location) if authority is None: - response['location'] = httplib2.urlparse.urljoin(uri, location) + response['location'] = urljoin(uri, location) pywikibot.debug(u"Relative redirect: changed [%s] to [%s]" % (location, response['location']), _logger) diff --git a/tests/http_tests.py b/tests/http_tests.py index 55698a5..abef94a 100644 --- a/tests/http_tests.py +++ b/tests/http_tests.py @@ -108,6 +108,12 @@
self.assertEqual(organisation, 'TuxFamily.org non-profit organization')
+ def test_http_504(self): + """Test that a HTTP 504 raises the correct exception.""" + self.assertRaises(pywikibot.Server504Error, + http.fetch, + uri='http://getstatuscode.com/504') +
class ThreadedHttpTestCase(TestCase):
pywikibot-commits@lists.wikimedia.org