From 116e528a7d675d099fc88f8dcae126f6f85da33b Mon Sep 17 00:00:00 2001 From: Renaud Walder Date: Sat, 16 May 2026 13:36:18 +0200 Subject: [PATCH] Simplify the Start Stop Pause process (v-and-v/testium#20) --- .../interpreter/test_items/test_item.py | 100 ++++++++++-------- src/testium/main_win/test_runner.py | 2 +- 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/src/testium/interpreter/test_items/test_item.py b/src/testium/interpreter/test_items/test_item.py index 4b47d9c..867b509 100644 --- a/src/testium/interpreter/test_items/test_item.py +++ b/src/testium/interpreter/test_items/test_item.py @@ -20,52 +20,64 @@ class TestItem: def test_run(f): @wraps(f) def wrapper(self): - if not self.skipped: - if self.enabled: - self.run_test_init() - # Conditional execution - raw_condition = self._prms.getParam( - "condition", default=None, processed=False - ) - if raw_condition is None: - condition = True - else: - c = self._prms.expanse(raw_condition) - if isinstance(c, bool): - condition = c - else: - condition = False - c = False - - if raw_condition == c: - msg = f'"{c}"' - else: - msg = f'"{raw_condition}" --> "{c}"' - - # Do we have to skip the test because of a true condition ? - if condition: - if not raw_condition is None: - msg = "condition met: " + msg - self.result.reported = {"input_condition": msg} - print(msg) - # Test preparation - self.run_before_test() - # Test execution - f(self) - else: - msg = "condition not met: " + msg - self.result.set(TestValue.NORUN, msg) - self.result.reported = {"input_condition": msg} - self.run_test_end() - else: - self.result.set(TestValue.NORUN, "test disabled") - print("Test is disabled.") - else: + if self.skipped: self.result.set(TestValue.NORUN, "test skipped") print("Test is skipped.") + return self.result + + if not self.enabled: + self.result.set(TestValue.NORUN, "test disabled") + print("Test is disabled.") + return self.result + + self.run_test_init() + + while self._is_paused: + sleep(0.2) + if self.isStopped() : + self.result.set(TestValue.NORUN, "test stopped") + print("Test is Stopped.") + self._is_stopped = False # Restore state for next run + return self.result + + # Conditional execution + raw_condition = self._prms.getParam( + "condition", default=None, processed=False + ) + if raw_condition is None: + condition = True + else: + c = self._prms.expanse(raw_condition) + if isinstance(c, bool): + condition = c + else: + condition = False + c = False + + if raw_condition == c: + msg = f'"{c}"' + else: + msg = f'"{raw_condition}" --> "{c}"' + + # Do we have to skip the test because of a true condition ? + if condition: + if not raw_condition is None: + msg = "condition met: " + msg + self.result.reported = {"input_condition": msg} + print(msg) + # Test preparation + self.run_before_test() + # Test execution + f(self) + else: + msg = "condition not met: " + msg + self.result.set(TestValue.NORUN, msg) + self.result.reported = {"input_condition": msg} + self.run_test_end() return self.result + return wrapper @@ -255,8 +267,6 @@ class TestItem: self._sendStatusStarted() if self._is_breakpoint: self._is_paused = True - while self._is_paused: - sleep(0.2) if self.is_container: self.report.incLevel() @@ -274,9 +284,6 @@ class TestItem: if self.is_container: self.report.decLevel() - while self._is_paused: - sleep(0.2) - # Post evaluation of the test result self.process_result() # expected_result treatment @@ -310,6 +317,7 @@ class TestItem: self.process_report(self._reported) self.report.addTest(self, self.result, rk) self._sendStatusFinished() + def process_result(self): if self._post_eval is None: diff --git a/src/testium/main_win/test_runner.py b/src/testium/main_win/test_runner.py index ad77e55..c3ca591 100644 --- a/src/testium/main_win/test_runner.py +++ b/src/testium/main_win/test_runner.py @@ -176,7 +176,7 @@ class TestRunner: w.actionOpenTest.setDisabled(True) w.actionExit.setDisabled(True) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(icon_prefix() + "/pause.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(icon_prefix() + "/pause2.png"), QtGui.QIcon.Normal, QtGui.QIcon.On) w.actionStart_test.setIcon(icon) w.actionStart_test.setText("Pause test") w.actionPreferences.setDisabled(True)