def testRecvTimeout(self):
# Test recv() timeout
_timeout = 0.02
- self.sock.connect(self.addr_remote)
- self.sock.settimeout(_timeout)
- _t1 = time.time()
- self.assertRaises(socket.error, self.sock.recv, 1024)
- _t2 = time.time()
+ with support.transient_internet(self.addr_remote[0]):
+ self.sock.connect(self.addr_remote)
+ self.sock.settimeout(_timeout)
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
+ _t1 = time.time()
+ self.assertRaises(socket.timeout, self.sock.recv, 1024)
+ _t2 = time.time()
+
+ _delta = abs(_t1 - _t2)
+ self.assertTrue(_delta < _timeout + self.fuzz,
+ "timeout (%g) is %g seconds more than expected (%g)"
+ %(_delta, self.fuzz, _timeout))
def testAcceptTimeout(self):
# Test accept() timeout