def run_write(output_queue): write_pipe, lua_read_pipe = [None, None] try: write_pipe = Pipe("env1", "write", 'w', "mame/pipes") lua_read_pipe = setup_pipe(write_pipe) write_pipe.writeln("test") output_queue.put(lua_read_pipe.readline()) finally: close_pipes(write_pipe, lua_read_pipe)
def test_write(self): write_pipe, lua_read_pipe = [None, None] try: write_pipe = Pipe("env1", "write", 'w', "mame/pipes") lua_read_pipe = setup_pipe(write_pipe) write_pipe.writeln("test") assert_that(lua_read_pipe.readline(), equal_to("test\n")) finally: close_pipes(write_pipe, lua_read_pipe)
def test_write_to_read_pipe(self): read_pipe, lua_write_pipe = [None, None] try: read_pipe = Pipe("env1", "read", 'r', "mame/pipes") lua_write_pipe = setup_pipe(read_pipe) with self.assertRaises(IOError) as context: read_pipe.writeln("TEST") assert_that(str(context.exception), contains_string("Attempted to write to '/home/michael/dev/MAMEToolkit/test/emulator/mame/pipes/read-env1.pipe' in 'r' mode")) finally: close_pipes(read_pipe, lua_write_pipe)