

def tearDown(self):
    try:
        self.proxyServerFactory.protoInstance.transport.loseConnection()
    except AttributeError:
        pass
    try:
        pi = self.proxyServerFactory.clientFactoryInstance.protoInstance
        p.transport.loseConnection()
    except AttributeError:
        pass
    try:
        self.clientProtocol.transport.loseConnection()
    except AttributeError:
        pass
    try:
        self.serverProtocol.transport.loseConnection()
    except AttributeError:
        pass
    return defer.gatherResults([defer.maybeDeferred(p.stopListening) for p in self.openPorts])

dataset/ETHPy150Open twisted/twisted/twisted/test/test_protocols.py PortforwardingTests.tearDown/VarMisuse@49/64 `pi`->`p`