def _read_from_stdout(self, cmd, args): # Retrieve string of setting contents for comparison to input settings backup = sys.stdout # backup the environment sys.stdout = StringIO() # Capture the output of next statement main(cmd, args) settings = sys.stdout.getvalue() # release the output and store sys.stdout.close() # Restore the environment sys.stdout = backup return settings