def port(self, portNumber, factory, interface): """ Create, start, and return a new L{Port}, also tracking it so it can be stopped in the test tear down. """ p = Port(portNumber, factory, interface=interface) p.startListening() self.ports.append(p) return p
def test_connectionLostFailed(self): """ L{Port.stopListening} returns a L{Deferred} which errbacks if L{Port.connectionLost} raises an exception. """ port = Port(12345, ServerFactory()) port.connected = True port.connectionLost = lambda reason: 1 // 0 return self.assertFailure(port.stopListening(), ZeroDivisionError)