示例#1
0
 def test_addAfterStart(self):
     """
     Adding a socket to an L{InheritedSocketDispatcher} after it has already
     been started results in it immediately starting reading.
     """
     reactor = ReaderAdder()
     dispatcher = InheritedSocketDispatcher(None)
     dispatcher.reactor = reactor
     dispatcher.startDispatching()
     dispatcher.addSocket()
     self.assertEquals(reactor.getReaders(), dispatcher._subprocessSockets)
 def test_nonBlocking(self):
     """
     Creating a L{_SubprocessSocket} via
     L{InheritedSocketDispatcher.addSocket} results in a non-blocking
     L{socket.socket} object being assigned to its C{skt} attribute, as well
     as a non-blocking L{socket.socket} object being returned.
     """
     dispatcher = InheritedSocketDispatcher(None)
     dispatcher.startDispatching()
     reactor = ReaderAdder()
     dispatcher.reactor = reactor
     inputSocket = dispatcher.addSocket()
     outputSocket = reactor.readers[-1]
     self.assertTrue(isNonBlocking(inputSocket), "Input is blocking.")
     self.assertTrue(isNonBlocking(outputSocket), "Output is blocking.")