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

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

Commit Message

Ke Xu March 14, 2023, 9:01 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
 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(-)
  

Patch

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):