Testing scheduling

Ark cloudneozero at gmail.com
Mon Apr 27 17:47:43 CEST 2015


Hi everyone.
I'm trying to test scheduling with asyncio. I have a function that executes
call_later to run a method later in the future. Basically, what I'm trying
to do is what you do in Twisted with the method callLater of a fictional
Clock, to simulate time passage with the advance method.

class ClientCalculationTestCase(unittest.TestCase):
    def setUp(self):
        self.tr = proto_helpers.StringTransportWithDisconnection()
        self.clock = task.Clock()
        self.proto = RemoteCalculationClient()
        self.tr.protocol = self.proto
        self.proto.callLater = self.clock.callLater
        self.proto.makeConnection(self.tr)

    def test_timeout(self):
        d = self.proto.add(9, 4)
        self.assertEqual(self.tr.value(), 'add 9 4\r\n')
        self.clock.advance(self.proto.timeOut)
        return self.assertFailure(d, ClientTimeoutError)


Is there any way to do this with asyncio?. Thanks for any help provided.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150427/41bde2c6/attachment.html>


More information about the Python-list mailing list