diff options
| author | Augie Fackler <durin42@gmail.com> | 2010-10-05 08:10:02 -0500 |
|---|---|---|
| committer | Augie Fackler <durin42@gmail.com> | 2010-10-05 08:10:02 -0500 |
| commit | 5c1b00a03221f55ac48b0d34030160cf55b4225f (patch) | |
| tree | db136752e78022df9369a40cf16f1045cba6ccb5 /python2/httplib2/test/test_no_socket.py | |
| parent | a9d82cae27af6fe29929097214cf6d3cc54fbaa0 (diff) | |
| download | httplib2-5c1b00a03221f55ac48b0d34030160cf55b4225f.tar.gz | |
proxy support: degrade gracefully when socket.socket is unavailable
This should allow httplib2 to continue to work even on platforms like
appengine where the socket module exists but has no socket attribute.
Diffstat (limited to 'python2/httplib2/test/test_no_socket.py')
| -rw-r--r-- | python2/httplib2/test/test_no_socket.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python2/httplib2/test/test_no_socket.py b/python2/httplib2/test/test_no_socket.py new file mode 100644 index 0000000..66ba056 --- /dev/null +++ b/python2/httplib2/test/test_no_socket.py @@ -0,0 +1,24 @@ +"""Tests for httplib2 when the socket module is missing. + +This helps ensure compatibility with environments such as AppEngine. +""" +import os +import sys +import unittest + +import httplib2 + +class MissingSocketTest(unittest.TestCase): + def setUp(self): + self._oldsocks = httplib2.socks + httplib2.socks = None + + def tearDown(self): + httplib2.socks = self._oldsocks + + def testProxyDisabled(self): + proxy_info = httplib2.ProxyInfo('blah', + 'localhost', 0) + client = httplib2.Http(proxy_info=proxy_info) + self.assertRaises(httplib2.ProxiesUnavailableError, + client.request, 'http://localhost:-1/') |
