コード例 #1
0
    def create_ioloop_with_timeout(self):
        """Create IOLoop with test timeout and schedule cleanup to close it

        """
        ioloop = select_connection.IOLoop()
        self.addCleanup(ioloop.close)

        def _on_test_timeout():
            """Called when test times out"""
            LOGGER.info('%s TIMED OUT (%s)', datetime.datetime.utcnow(), self)
            self.fail('Test timed out')

        ioloop.call_later(self.DEFAULT_TEST_TIMEOUT, _on_test_timeout)

        return ioloop
    def setUp(self):
        select_type_patch = mock.patch.multiple(select_connection,
                                                SELECT_TYPE=self.SELECT_POLLER)
        select_type_patch.start()
        self.addCleanup(select_type_patch.stop)

        self.ioloop = select_connection.IOLoop()
        self.addCleanup(setattr, self, 'ioloop', None)

        activate_poller_patch = mock.patch.object(
            self.ioloop._poller,
            'activate_poller',
            wraps=self.ioloop._poller.activate_poller)
        activate_poller_patch.start()
        self.addCleanup(activate_poller_patch.stop)

        deactivate_poller_patch = mock.patch.object(
            self.ioloop._poller,
            'deactivate_poller',
            wraps=self.ioloop._poller.deactivate_poller)
        deactivate_poller_patch.start()
        self.addCleanup(deactivate_poller_patch.stop)
コード例 #3
0
 def setUp(self):
     select_connection.SELECT_TYPE = self.SELECT_POLLER
     self.ioloop = select_connection.IOLoop()