Simplify the Start Stop Pause process (v-and-v/testium#20)
This commit is contained in:
@@ -20,52 +20,64 @@ class TestItem:
|
|||||||
def test_run(f):
|
def test_run(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def wrapper(self):
|
def wrapper(self):
|
||||||
if not self.skipped:
|
if 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:
|
|
||||||
self.result.set(TestValue.NORUN, "test skipped")
|
self.result.set(TestValue.NORUN, "test skipped")
|
||||||
print("Test is 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 self.result
|
||||||
|
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
@@ -255,8 +267,6 @@ class TestItem:
|
|||||||
self._sendStatusStarted()
|
self._sendStatusStarted()
|
||||||
if self._is_breakpoint:
|
if self._is_breakpoint:
|
||||||
self._is_paused = True
|
self._is_paused = True
|
||||||
while self._is_paused:
|
|
||||||
sleep(0.2)
|
|
||||||
|
|
||||||
if self.is_container:
|
if self.is_container:
|
||||||
self.report.incLevel()
|
self.report.incLevel()
|
||||||
@@ -274,9 +284,6 @@ class TestItem:
|
|||||||
if self.is_container:
|
if self.is_container:
|
||||||
self.report.decLevel()
|
self.report.decLevel()
|
||||||
|
|
||||||
while self._is_paused:
|
|
||||||
sleep(0.2)
|
|
||||||
|
|
||||||
# Post evaluation of the test result
|
# Post evaluation of the test result
|
||||||
self.process_result()
|
self.process_result()
|
||||||
# expected_result treatment
|
# expected_result treatment
|
||||||
@@ -311,6 +318,7 @@ class TestItem:
|
|||||||
self.report.addTest(self, self.result, rk)
|
self.report.addTest(self, self.result, rk)
|
||||||
self._sendStatusFinished()
|
self._sendStatusFinished()
|
||||||
|
|
||||||
|
|
||||||
def process_result(self):
|
def process_result(self):
|
||||||
if self._post_eval is None:
|
if self._post_eval is None:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ class TestRunner:
|
|||||||
w.actionOpenTest.setDisabled(True)
|
w.actionOpenTest.setDisabled(True)
|
||||||
w.actionExit.setDisabled(True)
|
w.actionExit.setDisabled(True)
|
||||||
icon = QtGui.QIcon()
|
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.setIcon(icon)
|
||||||
w.actionStart_test.setText("Pause test")
|
w.actionStart_test.setText("Pause test")
|
||||||
w.actionPreferences.setDisabled(True)
|
w.actionPreferences.setDisabled(True)
|
||||||
|
|||||||
Reference in New Issue
Block a user