コード例 #1
0
ファイル: badhack.py プロジェクト: tomprince/agentforhire
def loopbackAsync(server, client, server_addr=None, client_addr=None):
    """
    I'm a copy of twisted.protocols.loopback.loopbackAsync with support for
    choosing addresses.  Am I a bad idea?  You bet, I am.
    """
    serverToClient = loopback._LoopbackQueue()
    clientToServer = loopback._LoopbackQueue()
    
    server.makeConnection(FakeTransport(serverToClient, client_addr, server_addr))
    client.makeConnection(FakeTransport(clientToServer, server_addr, client_addr))
    
    return loopback._loopbackAsyncBody(
        server, serverToClient, client, clientToServer,
        loopback.identityPumpPolicy)
コード例 #2
0
ファイル: test_loopback.py プロジェクト: hu19891110/twisted
    def test_identityPumpPolicy(self):
        """
        L{identityPumpPolicy} is a pump policy which calls the target's
        C{dataReceived} method one for each string in the queue passed to it.
        """
        bytes = []
        client = Protocol()
        client.dataReceived = bytes.append
        queue = loopback._LoopbackQueue()
        queue.put(b"foo")
        queue.put(b"bar")
        queue.put(None)

        loopback.identityPumpPolicy(queue, client)

        self.assertEqual(bytes, [b"foo", b"bar"])
コード例 #3
0
ファイル: test_loopback.py プロジェクト: 0004c/VTK
    def test_identityPumpPolicy(self):
        """
        L{identityPumpPolicy} is a pump policy which calls the target's
        C{dataReceived} method one for each string in the queue passed to it.
        """
        bytes = []
        client = Protocol()
        client.dataReceived = bytes.append
        queue = loopback._LoopbackQueue()
        queue.put(b"foo")
        queue.put(b"bar")
        queue.put(None)

        loopback.identityPumpPolicy(queue, client)

        self.assertEqual(bytes, [b"foo", b"bar"])
コード例 #4
0
ファイル: test_loopback.py プロジェクト: hu19891110/twisted
    def test_collapsingPumpPolicy(self):
        """
        L{collapsingPumpPolicy} is a pump policy which calls the target's
        C{dataReceived} only once with all of the strings in the queue passed
        to it joined together.
        """
        bytes = []
        client = Protocol()
        client.dataReceived = bytes.append
        queue = loopback._LoopbackQueue()
        queue.put(b"foo")
        queue.put(b"bar")
        queue.put(None)

        loopback.collapsingPumpPolicy(queue, client)

        self.assertEqual(bytes, [b"foobar"])
コード例 #5
0
ファイル: test_loopback.py プロジェクト: 0004c/VTK
    def test_collapsingPumpPolicy(self):
        """
        L{collapsingPumpPolicy} is a pump policy which calls the target's
        C{dataReceived} only once with all of the strings in the queue passed
        to it joined together.
        """
        bytes = []
        client = Protocol()
        client.dataReceived = bytes.append
        queue = loopback._LoopbackQueue()
        queue.put(b"foo")
        queue.put(b"bar")
        queue.put(None)

        loopback.collapsingPumpPolicy(queue, client)

        self.assertEqual(bytes, [b"foobar"])