示例#1
0
 def test_use_stdio(self):
     port = Port()
     self.assertEqual(0, port.in_d)
     self.assertEqual(1, port.out_d)
     port = Port(use_stdio=True)
     self.assertEqual(0, port.in_d)
     self.assertEqual(1, port.out_d)
示例#2
0
 def test_slow_write(self):
     write = os.write
     os.write = lambda d, data: 1
     try:
         port = Port(packet=1)
         self.assertEqual(9, port.write(Atom(b"test")))
     finally:
         os.write = write
示例#3
0
 def test_slow_write(self):
     write = os.write
     os.write = lambda d, data: 1
     try:
         port = Port(packet=1)
         self.assertEqual(9, port.write(Atom(b"test")))
     finally:
         os.write = write
示例#4
0
def main(argv=None):
    parser = get_option_parser()
    options, args = parser.parse_args(argv)
    port = Port(use_stdio=options.stdio,
                packet=options.packet,
                compressed=options.compressed,
                buffer_size=options.buffer_size)
    erlang.setup(port)
示例#5
0
 def test_no_data_written(self):
     write = os.write
     os.write = lambda d, data: 0
     try:
         port = Port()
         self.assertRaises(EOFError, port.write, b"test")
     finally:
         os.write = write
示例#6
0
    def test_close_on_read(self):
        def test_read(d, buffer_size):
            raise OSError(errno.EPIPE, "Pipe closed")

        read = os.read
        os.read = test_read
        try:
            port = Port()
            self.assertRaises(EOFError, port.read)
        finally:
            os.read = read
示例#7
0
    def test_error_on_read(self):
        def test_read(d, buffer_size):
            raise OSError()

        read = os.read
        os.read = test_read
        try:
            port = Port()
            self.assertRaises(OSError, port.read)
        finally:
            os.read = read
示例#8
0
    def test_error_on_write(self):
        def test_write(d, data):
            raise OSError()

        write = os.write
        os.write = test_write
        try:
            port = Port()
            self.assertRaises(OSError, port.write, b"test")
        finally:
            os.write = write
示例#9
0
 def test_descriptors(self):
     port = Port(descriptors=(10, 20))
     self.assertEqual(10, port.in_d)
     self.assertEqual(20, port.out_d)
示例#10
0
 def test_nouse_stdio(self):
     port = Port(use_stdio=False)
     self.assertEqual(3, port.in_d)
     self.assertEqual(4, port.out_d)
示例#11
0
 def __init__(self, **kwargs):
     r, self.out_d = os.pipe()
     self.in_d, w = os.pipe()
     self.port = Port(descriptors=(r, w), **kwargs)