[V2,1/2] framework/test_result: fix unsafe __set_test_case
Commit Message
Without a pre-append check, __set_test_case method will append redundant
elements when setting but locating the result at the first element. If
this method is called several times, the outcome will de-organize in data
structure.
There is a pre-append check in __set_test_suite and __set_test_suite. This
implementation imitated the methods above.
Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
framework/test_result.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -232,8 +232,9 @@ class Result(object):
def __set_test_case(self, test_case):
cases = self.__current_cases()
- cases.append(test_case)
- cases.append([])
+ if test_case not in cases:
+ cases.append(test_case)
+ cases.append([])
self.__test_case = cases.index(test_case)
def __get_test_case(self):