Commits

Andriy Kornatskyy  committed 3e9f8cc

Fixed compatibility issue with python 2.4, 2.5, 3.2 and 3.3.

  • Participants
  • Parent commits eed1618

Comments (0)

Files changed (3)

File src/wheezy/core/comp.py

     from Cookie import SimpleCookie  # noqa
 
 if PY3:  # pragma: nocover
+    from http.client import HTTPConnection
     from urllib.parse import urlencode
     from urllib.parse import urljoin
     from urllib.parse import urlparse
     from urllib.parse import urlsplit
     from urllib.parse import urlunsplit
 else:  # pragma: nocover
+    from httplib import HTTPConnection
     from urllib import urlencode  # noqa
     from urlparse import urljoin  # noqa
     from urlparse import urlparse  # noqa

File src/wheezy/core/httpclient.py

 """
 """
 
-from httplib import HTTPConnection
-
 from wheezy.core.collections import attrdict
 from wheezy.core.collections import defaultdict
 from wheezy.core.comp import Decimal
+from wheezy.core.comp import HTTPConnection
 from wheezy.core.comp import SimpleCookie
 from wheezy.core.comp import json_loads
 from wheezy.core.comp import urlencode
             application specific use cases, e.g. remote web server API, etc.
         """
         r = urlparse(url)
-        self.connection = HTTPConnection(r.netloc)
+        self.connection = HTTPConnection(r[1])  # netloc
         self.default_headers = headers and headers or {}
         self.path = r.path
         self.method = None

File src/wheezy/core/tests/test_httpclient.py

     def test_json(self):
         """ json response.
         """
+        from wheezy.core import httpclient
         from wheezy.core.comp import ntob
+        patcher = patch.object(httpclient, 'json_loads')
+        mock_json_loads = patcher.start()
+        mock_json_loads.return_value = {}
         self.headers.append(('content-type',
                              'application/json; charset=UTF-8'))
         self.mock_response.read.return_value = ntob('{}', 'utf-8')
         self.client.get('auth/token')
         assert {} == self.client.json
+        patcher.stop()