コード例 #1
0
class ReceiverThreadedTestMixIn(object):
    """Base class for XMPP receiver streams tests, using the
    `ThreadPool`"""
    def make_loop(self, handlers):
        """Return a main loop object for use with this test suite."""
        # pylint: disable=W0201
        self.loop = ThreadPool(XMPPSettings({"upoll_interval": 0.1}), handlers)

    def start_transport(self, handlers):
        """Create a listening socket for the tested stream, 
        a transport a main loop and create a client connectiong to the
        socket."""
        super(ReceiverThreadedTestMixIn, self).start_transport(handlers)
        self.loop.start()

    def tearDown(self):
        """Tear down the test case object."""
        if self.loop:
            logger.debug("Stopping the thread pool")
            try:
                self.loop.stop(True, 2)
            except Exception: # pylint: disable=W0703
                logger.exception("self.loop.stop failed:")
            else:
                logger.debug("  done (or timed out)")
            self.loop.event_dispatcher.flush(False)
        super(ReceiverThreadedTestMixIn, self).tearDown()
コード例 #2
0
class InitiatorThreadedTestMixIn(object):
    """Base class for XMPP initiator streams tests, using the
    `ThreadPool` instead of an asynchronous event loop."""
    def make_loop(self, handlers):
        """Return a main loop object for use with this test suite."""
        # pylint: disable=W0201
        self.loop = ThreadPool(XMPPSettings({"upoll_interval": 0.1}), handlers)

    def connect_transport(self):
        """Start a test server and connect the transport to it."""
        InitiatorSelectTestCase.connect_transport(self)
        self.loop.start()

    def tearDown(self):
        """Tear down the test case object."""
        if self.loop:
            logger.debug("Stopping the thread pool")
            try:
                self.loop.stop(True, 2)
            except Exception: # pylint: disable=W0703
                logger.exception("self.loop.stop failed:")
            else:
                logger.debug("  done (or timed out)")
            self.loop.event_dispatcher.flush(False)
        super(InitiatorThreadedTestMixIn, self).tearDown()
コード例 #3
0
ファイル: server_listener.py プロジェクト: Jajcus/pyxmpp2
class TestListenerThread(TestListenerSelect):
    def setUp(self):
        self._loop = None
        super(TestListenerThread, self).setUp()
    def make_loop(self, handlers):
        """Return a main loop object for use with this test suite."""
        self._loop = ThreadPool(None, handlers)
        self._loop.start()
        return self._loop
    def tearDown(self):
        if self._loop:
            logger.debug("Stopping the thread pool")
            try:
                self._loop.stop(True, 2)
            except Exception: # pylint: disable=W0703
                logger.exception("self.loop.stop failed:")
            else:
                logger.debug("  done (or timed out)")
            self._loop.event_dispatcher.flush(False)
        super(TestListenerThread, self).tearDown()
コード例 #4
0
class TestListenerThread(TestListenerSelect):
    def setUp(self):
        self._loop = None
        super(TestListenerThread, self).setUp()
    def make_loop(self, handlers):
        """Return a main loop object for use with this test suite."""
        self._loop = ThreadPool(None, handlers)
        self._loop.start()
        return self._loop
    def tearDown(self):
        if self._loop:
            logger.debug("Stopping the thread pool")
            try:
                self._loop.stop(True, 2)
            except Exception: # pylint: disable=W0703
                logger.exception("self.loop.stop failed:")
            else:
                logger.debug("  done (or timed out)")
            self._loop.event_dispatcher.flush(False)
        super(TestListenerThread, self).tearDown()
コード例 #5
0
ファイル: server_listener.py プロジェクト: Jajcus/pyxmpp2
 def make_loop(self, handlers):
     """Return a main loop object for use with this test suite."""
     self._loop = ThreadPool(None, handlers)
     self._loop.start()
     return self._loop
コード例 #6
0
 def make_loop(self, handlers):
     """Return a main loop object for use with this test suite."""
     # pylint: disable=W0201
     self.loop = ThreadPool(XMPPSettings({"upoll_interval": 0.1}), handlers)
コード例 #7
0
 def make_loop(self, handlers):
     """Return a main loop object for use with this test suite."""
     self._loop = ThreadPool(None, handlers)
     self._loop.start()
     return self._loop