def is_successful(self):
"""Interpret the result of the test case.
It allows getting the result of TestCase. It completes run()
which only returns the execution status.
It can be overriden if checking result is not suitable.
Returns:
TestCase.EX_OK if result is 'PASS'.
TestCase.EX_TESTCASE_FAILED otherwise.
"""
try:
assert self.criteria
assert self.result is not None
if (not isinstance(self.result, str) and
not isinstance(self.criteria, str)):
if self.result >= self.criteria:
return TestCase.EX_OK
else:
# Backward compatibility
# It must be removed as soon as TestCase subclasses
# stop setting result = 'PASS' or 'FAIL'.
# In this case criteria is unread.
self.__logger.warning(
"Please update result which must be an int!")
if self.result == 'PASS':
return TestCase.EX_OK
except AssertionError:
self.__logger.error("Please run test before checking the results")
return TestCase.EX_TESTCASE_FAILED
评论列表
文章目录