def setUp(self): self.stdin = StringIO() self.stdout = StringIO() self.rpc = rpc.JSONRPCServer(self.stdin, self.stdout)
class TestJSONRPCServer(unittest.TestCase): def setUp(self): self.stdin = StringIO() self.stdout = StringIO() self.rpc = rpc.JSONRPCServer(self.stdin, self.stdout) def write(self, s): self.stdin.seek(0) self.stdin.truncate() self.stdout.seek(0) self.stdout.truncate() self.stdin.write(s) self.stdin.seek(0) def read(self): value = self.stdout.getvalue() self.stdin.seek(0) self.stdin.truncate() self.stdout.seek(0) self.stdout.truncate() return value