avocado.core.result: Handle incorrect number of total tests

When the total number of tests is lower than number of executed tests,
avocado reports incorrect number of tests. Let's increase the number of
tests in such case.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 076a4fc9
...@@ -137,7 +137,10 @@ class TestResult(object): ...@@ -137,7 +137,10 @@ class TestResult(object):
self.failed + self.warned + self.failed + self.warned +
self.skipped + self.interrupted) self.skipped + self.interrupted)
other_skipped_count = self.tests_total - valid_results_count other_skipped_count = self.tests_total - valid_results_count
self.skipped += other_skipped_count if other_skipped_count > 0:
self.skipped += other_skipped_count
else:
self.tests_total -= other_skipped_count
def start_tests(self): def start_tests(self):
""" """
......
...@@ -85,5 +85,20 @@ class JSONResultTest(unittest.TestCase): ...@@ -85,5 +85,20 @@ class JSONResultTest(unittest.TestCase):
check_item("[skip]", res["skip"], 4) check_item("[skip]", res["skip"], 4)
check_item("[total]", res["total"], 13) check_item("[total]", res["total"], 13)
def testNegativeStatus(self):
def check_item(name, value, exp):
self.assertEqual(value, exp, "Result%s is %s and not %s\n%s"
% (name, value, exp, res))
self.test_result.tests_total = 0
self.test_result.start_test(self.test1)
self.test_result.check_test(self.test1.get_state())
self.test_result.end_tests()
res = json.loads(self.test_result.json)
check_item("[total]", res["total"], 1)
check_item("[skip]", res["skip"], 0)
check_item("[pass]", res["pass"], 1)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册