def test_timeout(self): pool = HTTPConnectionPool(HOST, PORT, timeout=0.1) try: r = pool.get_url('/sleep', fields={'seconds': 0.2}) self.fail("Failed to raise TimeoutError exception") except TimeoutError, e: pass
class TestConnectionPool(unittest.TestCase): def __init__(self, *args, **kw): # Test for dummy server... self.http_pool = HTTPConnectionPool(HOST, PORT) try: r = self.http_pool.get_url('/', retries=1) if r.data != "Dummy server!": raise Exception("Got unexpected response: %s" % r.data) except Exception, e: raise Exception("Dummy server not running, make sure HOST and PORT correspond to the dummy server: %s" % e.message) return super(TestConnectionPool, self).__init__(*args, **kw)