diff mbox series

[V2,1/2] framework/test_result: fix unsafe __set_test_case

Message ID 20230315015655.768885-2-ke1.xu@intel.com (mailing list archive)
State New
Headers show
Series fix result output overwriting when using multiple lines in execution configuration for one suite. | expand

Commit Message

Ke Xu March 15, 2023, 1:56 a.m. UTC
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

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(-)
diff mbox series


diff --git a/framework/test_result.py b/framework/test_result.py
index b62ed120..081b7256 100644
--- a/framework/test_result.py
+++ b/framework/test_result.py
@@ -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):