| 1 |
"""Tests for httplib2 when the socket module is missing. |
| 2 |
|
| 3 |
This helps ensure compatibility with environments such as AppEngine. |
| 4 |
""" |
| 5 |
import os |
| 6 |
import sys |
| 7 |
import unittest |
| 8 |
|
| 9 |
import httplib2 |
| 10 |
|
| 11 |
|
| 12 |
class MissingSocketTest(unittest.TestCase): |
| 13 |
def setUp(self): |
| 14 |
self._oldsocks = httplib2.socks |
| 15 |
httplib2.socks = None |
| 16 |
|
| 17 |
def tearDown(self): |
| 18 |
httplib2.socks = self._oldsocks |
| 19 |
|
| 20 |
def testProxyDisabled(self): |
| 21 |
proxy_info = httplib2.ProxyInfo("blah", "localhost", 0) |
| 22 |
client = httplib2.Http(proxy_info=proxy_info) |
| 23 |
self.assertRaises( |
| 24 |
httplib2.ProxiesUnavailableError, client.request, "http://localhost:-1/" |
| 25 |
) |