def test_protocolLogPrefix(self): """ L{ProtocolWrapper.logPrefix} is customized to mention both the original protocol and the wrapper. """ server = Server() factory = policies.WrappingFactory(server) protocol = factory.buildProtocol(address.IPv4Address("TCP", "127.0.0.1", 35)) self.assertEqual("EchoProtocol (ProtocolWrapper)", protocol.logPrefix())
def test_protocolLogPrefix(self): """ L{ProtocolWrapper.logPrefix} is customized to mention both the original protocol and the wrapper. """ server = Server() factory = policies.WrappingFactory(server) protocol = factory.buildProtocol( address.IPv4Address('TCP', '127.0.0.1', 35)) self.assertEqual("EchoProtocol (ProtocolWrapper)", protocol.logPrefix())
def test_protocolLogPrefixFallback(self): """ If the wrapped protocol doesn't have a L{logPrefix} method, L{ProtocolWrapper.logPrefix} falls back to the protocol class name. """ class NoProtocol: pass server = Server() server.protocol = NoProtocol factory = policies.WrappingFactory(server) protocol = factory.buildProtocol( address.IPv4Address("TCP", "127.0.0.1", 35)) self.assertEqual("NoProtocol (ProtocolWrapper)", protocol.logPrefix())
def test_protocolLogPrefixFallback(self): """ If the wrapped protocol doesn't have a L{logPrefix} method, L{ProtocolWrapper.logPrefix} falls back to the protocol class name. """ class NoProtocol(object): pass server = Server() server.protocol = NoProtocol factory = policies.WrappingFactory(server) protocol = factory.buildProtocol( address.IPv4Address('TCP', '127.0.0.1', 35)) self.assertEqual("NoProtocol (ProtocolWrapper)", protocol.logPrefix())