From a3e449cc7d552db61c28fc309c0d8f712dc664c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sun, 26 Apr 2026 11:52:52 +0200 Subject: [PATCH] in batch mode, the dialog allways return FAIL, except if auto_result is defined (validation only). Co-Authored-By: Claude Sonnet 4.6 --- .../test_items/test_item_choices_dialog.py | 28 +++++++++++++------ .../test_items/test_item_image_dialog.py | 13 +++++---- .../test_items/test_item_msg_dialog.py | 8 +++++- .../test_items/test_item_note_dialog.py | 14 ++++++++-- .../test_items/test_item_question_dialog.py | 22 ++++++++++----- .../test_items/test_item_tested_references.py | 10 ++++++- .../test_items/test_item_value_dialog.py | 12 +++++++- 7 files changed, 81 insertions(+), 26 deletions(-) diff --git a/src/testium/interpreter/test_items/test_item_choices_dialog.py b/src/testium/interpreter/test_items/test_item_choices_dialog.py index 15449a8..d00cc2f 100644 --- a/src/testium/interpreter/test_items/test_item_choices_dialog.py +++ b/src/testium/interpreter/test_items/test_item_choices_dialog.py @@ -54,16 +54,26 @@ class TestItemChoicesDialog(TestItemDialogBase): self._print_choices(choices) if _is_interactive(): ans = input("Accept all? (y/n) [default: y]: ").strip().lower() + if ans in ('n', 'no'): + tm.delgd("cs_" + self._name) + self.result.set(TestValue.FAILURE, "Cancelled") + else: + val = self._all_checked(choices) + self.result.value = val + tm.setgd("cs_" + self._name, val) + self.result.set(TestValue.SUCCESS, str(val)) else: - ans = '' - if ans in ('n', 'no'): - tm.delgd("cs_" + self._name) - self.result.set(TestValue.FAILURE, "Cancelled") - else: - val = self._all_checked(choices) - self.result.value = val - tm.setgd("cs_" + self._name, val) - self.result.set(TestValue.SUCCESS, str(val)) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + if ar is None: + self.result.set(TestValue.FAILURE, 'Dialog not supported in batch mode') + elif ar == 'cancel': + tm.delgd("cs_" + self._name) + self.result.set(TestValue.FAILURE, "Cancelled") + else: + val = self._all_checked(choices) + self.result.value = val + tm.setgd("cs_" + self._name, val) + self.result.set(TestValue.SUCCESS, str(val)) return from interpreter.test_items.dialog_choices_files import choices_dialog ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None diff --git a/src/testium/interpreter/test_items/test_item_image_dialog.py b/src/testium/interpreter/test_items/test_item_image_dialog.py index 24b47a5..6956d9e 100644 --- a/src/testium/interpreter/test_items/test_item_image_dialog.py +++ b/src/testium/interpreter/test_items/test_item_image_dialog.py @@ -34,12 +34,15 @@ class TestItemImageDialog(TestItemDialogBase): if _is_text_mode(): if _is_interactive(): ans = input("Accept? (y/n) [default: y]: ").strip().lower() + self.result.set(TestValue.FAILURE if ans in ('n', 'no') else TestValue.SUCCESS) else: - ans = '' - if ans in ('n', 'no'): - self.result.set(TestValue.FAILURE) - else: - self.result.set(TestValue.SUCCESS) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + if ar is None: + self.result.set(TestValue.FAILURE, 'Dialog not supported in batch mode') + elif ar == 'cancel': + self.result.set(TestValue.FAILURE) + else: + self.result.set(TestValue.SUCCESS) return from interpreter.test_items.dialog_image_files import dialog_image ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None diff --git a/src/testium/interpreter/test_items/test_item_msg_dialog.py b/src/testium/interpreter/test_items/test_item_msg_dialog.py index 849af6f..110c6d9 100644 --- a/src/testium/interpreter/test_items/test_item_msg_dialog.py +++ b/src/testium/interpreter/test_items/test_item_msg_dialog.py @@ -28,7 +28,13 @@ class TestItemMsgDialog(TestItemDialogBase): if _is_text_mode(): if _is_interactive(): input("Press Enter to continue...") - self.result.set(TestValue.SUCCESS) + self.result.set(TestValue.SUCCESS) + else: + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + if ar is not None: + self.result.set(TestValue.SUCCESS) + else: + self.result.set(TestValue.FAILURE, 'Dialog not supported in batch mode') return from interpreter.test_items.dialog_msg_files import msg_dialog ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None diff --git a/src/testium/interpreter/test_items/test_item_note_dialog.py b/src/testium/interpreter/test_items/test_item_note_dialog.py index 8c0b010..88aa190 100644 --- a/src/testium/interpreter/test_items/test_item_note_dialog.py +++ b/src/testium/interpreter/test_items/test_item_note_dialog.py @@ -22,15 +22,25 @@ class TestItemNoteDialog(TestItemDialogBase): q = self._prms.expanse(self._question) print("Question:\n" + q) if _is_text_mode(): - lines = [] if _is_interactive(): print("Enter your note (type '.' on a new line to finish, empty line to cancel):") + lines = [] while True: line = input() if line == '.': break lines.append(line) - val = '\n'.join(lines) + val = '\n'.join(lines) + else: + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + av = self._prms.expanse(self._auto_value) if self._auto_value is not None else None + if ar is None: + self.result.set(TestValue.FAILURE, 'Dialog not supported in batch mode') + return + if ar == 'cancel': + self.result.set(TestValue.FAILURE, 'Dialog cancelled') + return + val = av if av is not None else '' tm.setgd(self.name(), val) print("\n" + ("-" * 80) + "\n") print("- Test note\n") diff --git a/src/testium/interpreter/test_items/test_item_question_dialog.py b/src/testium/interpreter/test_items/test_item_question_dialog.py index 3737ea9..beec964 100644 --- a/src/testium/interpreter/test_items/test_item_question_dialog.py +++ b/src/testium/interpreter/test_items/test_item_question_dialog.py @@ -25,14 +25,22 @@ class TestItemQuestionDialog(TestItemDialogBase): if _is_text_mode(): if _is_interactive(): ans = input("Answer yes (y) or no (n) [default: y]: ").strip().lower() + if ans in ('n', 'no'): + self.result.set(TestValue.FAILURE) + print('Answer: NO\n') + else: + self.result.set(TestValue.SUCCESS) + print('Answer: YES\n') else: - ans = '' - if ans in ('n', 'no'): - self.result.set(TestValue.FAILURE) - print('Answer: NO\n') - else: - self.result.set(TestValue.SUCCESS) - print('Answer: YES\n') + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + if ar is None: + self.result.set(TestValue.FAILURE, 'Dialog not supported in batch mode') + elif ar in ('no', 'cancel'): + self.result.set(TestValue.FAILURE) + print('Answer: NO\n') + else: + self.result.set(TestValue.SUCCESS) + print('Answer: YES\n') return from interpreter.test_items.dialog_question_files import question_dialog ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None diff --git a/src/testium/interpreter/test_items/test_item_tested_references.py b/src/testium/interpreter/test_items/test_item_tested_references.py index f661e4a..f9f1e2a 100644 --- a/src/testium/interpreter/test_items/test_item_tested_references.py +++ b/src/testium/interpreter/test_items/test_item_tested_references.py @@ -35,7 +35,15 @@ class TestItemTestedRefsDialog(TestItemDialogBase): ref, rev, serial = parts[0], parts[1], parts[2] result_rows.append(f"{ref}/{rev}/{serial}") val = ','.join(result_rows) - result = [val, True] + if _is_interactive(): + succ = True + else: + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + if ar is None: + self.result.set(TestValue.FAILURE, 'Dialog not supported in batch mode') + return + succ = ar != 'cancel' + result = [val, succ] else: from interpreter.test_items.tested_references_files import tested_refs_dialog ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None diff --git a/src/testium/interpreter/test_items/test_item_value_dialog.py b/src/testium/interpreter/test_items/test_item_value_dialog.py index 684be5f..18026ff 100644 --- a/src/testium/interpreter/test_items/test_item_value_dialog.py +++ b/src/testium/interpreter/test_items/test_item_value_dialog.py @@ -31,7 +31,17 @@ class TestItemValueDialog(TestItemDialogBase): prompt = f"Enter value [{d}]: " if d else "Enter value: " ans = input(prompt).strip() else: - ans = '' + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + av = self._prms.expanse(self._auto_value) if self._auto_value is not None else None + if ar is None: + print("Answer: \nDialog not supported in batch mode") + self.result.set(TestValue.FAILURE, 'Dialog not supported in batch mode') + return + if ar == 'cancel': + print("Answer: \nDialog cancelled") + self.result.set(TestValue.FAILURE, 'Dialog cancelled') + return + ans = av if av is not None else '' val = ans if ans else d tm.setgd(self.name(), val) print("Answer: " + str(val))