コード例 #1
0
 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
コード例 #2
0
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)