Exemple #1
0
    def testHangupConnectionTimeout(self):
        expectedException = IOError
        self.ms.socket.close()
        self.ms = MockServer(port=PortNumberGenerator.next(), hangupConnectionTimeout=0.1)
        self.ms.start()

        t0 = time()
        self.assertRaises(expectedException, lambda: urlopen(self.ms.myUrl).read())
        t1 = time()
        delta = t1 - t0
        self.assertTrue(0.09 < delta < 0.12, "Expected around 0.1, was %s" % delta)
        self.assertEqual(0, len(self.ms.requests))
Exemple #2
0
 def setUp(self):
     TestCase.setUp(self)
     self.ms = MockServer(port=PortNumberGenerator.next())