On 02/16/2012 03:11 AM, guyanhua wrote: > > Hi~ > The point is here: > commands API and utils.run both worked well. But sometimes, we give some > invalid options > on purpose of testing incorrect situations. In these cases, utils.run will > throw an exception > which we don't expect. > > Of course we can catch the exception and see what to do with the exit status, > but what is the > difference with commands API? I think commands API is more simple.
Just a question of standardization, we have utility functions to deal with subprocess and would like out tests to use it, nothing more than that. utils.run can take the param ignore_status=True if we don't really want to care about handling the exception. Then it'll return a cmdresult object that you can use to take the stdout and the return code as attributes of that object.... > On the other hand, we can set ignore_status to True, like the following: > cmd = "virsh version %s" % option > cmd_result = utils.run(cmd, ignore_status=True) > return cmd_result.exit_status > And there is still no difference with commands API. Just as you say here :) > So what do you think? I just proposed to be consistent as much as possible. If you strongly feel about using commands, then fine, but I see value in consistency. Cheers, Lucas _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
