Ejemplo n.º 1
0
 def test_forwardCommand(self):
     """
     L{main} forwards data from its input stream to a L{WorkerProtocol}
     instance which writes data to the output stream.
     """
     client = FakeAMP()
     clientTransport = StringTransport()
     client.makeConnection(clientTransport)
     client.callRemote(workercommands.Run, testCase="doesntexist")
     self.readStream = clientTransport.io
     self.readStream.seek(0, 0)
     main(self.fdopen)
     self.assertIn(b"No module named 'doesntexist'",
                   self.writeStream.getvalue())
Ejemplo n.º 2
0
 def test_forwardCommand(self):
     """
     L{main} forwards data from its input stream to a L{WorkerProtocol}
     instance which writes data to the output stream.
     """
     client = FakeAMP()
     clientTransport = StringTransport()
     client.makeConnection(clientTransport)
     client.callRemote(workercommands.Run, testCase=b"doesntexist")
     self.readStream = clientTransport.io
     self.readStream.seek(0, 0)
     main(self.fdopen)
     self.assertIn(
         b"No module named 'doesntexist'", self.writeStream.getvalue())
Ejemplo n.º 3
0
    def test_readInterrupted(self):
        """
        If reading the input stream fails with a C{IOError} with errno
        C{EINTR}, L{main} ignores it and continues reading.
        """

        class FakeStream(object):
            count = 0

            def read(oself, size):
                oself.count += 1
                if oself.count == 1:
                    raise IOError(errno.EINTR)
                else:
                    self.assertEqual((None, None, None), sys.exc_info())
                return ''

        self.readStream = FakeStream()
        main()
        self.assertEqual('', self.writeStream.getvalue())
Ejemplo n.º 4
0
    def test_readInterrupted(self):
        """
        If reading the input stream fails with a C{IOError} with errno
        C{EINTR}, L{main} ignores it and continues reading.
        """
        excInfos = []

        class FakeStream:
            count = 0

            def read(oself, size):
                oself.count += 1
                if oself.count == 1:
                    raise OSError(errno.EINTR)
                else:
                    excInfos.append(sys.exc_info())
                return b""

        self.readStream = FakeStream()
        main(self.fdopen)
        self.assertEqual(b"", self.writeStream.getvalue())
        self.assertEqual([(None, None, None)], excInfos)
Ejemplo n.º 5
0
 def test_empty(self):
     """
     If no data is ever written, L{main} exits without writing data out.
     """
     main(self.fdopen)
     self.assertEqual(b"", self.writeStream.getvalue())
Ejemplo n.º 6
0
 def test_empty(self):
     """
     If no data is ever written, L{main} exits without writing data out.
     """
     main(self.fdopen)
     self.assertEqual(b'', self.writeStream.getvalue())