From 7adf65cc2651a2979f9fedf73399fb2d7e8866f6 Mon Sep 17 00:00:00 2001 From: Lewis Gaul Date: Wed, 17 May 2023 15:26:52 -0700 Subject: [PATCH 1/2] Add back in the 'Message' column in terminal summary, following removal in cc0ec865 --- cafy_pytest/plugin.py | 56 ++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/cafy_pytest/plugin.py b/cafy_pytest/plugin.py index 39d8fba..ca49b6e 100644 --- a/cafy_pytest/plugin.py +++ b/cafy_pytest/plugin.py @@ -1809,31 +1809,39 @@ def pytest_terminal_summary(self, terminalreporter): # if mode present then print the reporting mode of per testcase as separate coloumn Testcase_mode else report same as ealier if hasattr(CafyLog,"hybrid_mode_dict") and CafyLog.hybrid_mode_dict.get('mode',None): - terminalreporter.write_line("\n TestCase Summary Status Table") - hybrid_mode_test_list = [] - hybrid_mode_dict=self.hybrid_mode_status_dict - mode_status="" - for k,v in self.testcase_dict.items(): - if v.name in hybrid_mode_dict.keys(): - mode_status=hybrid_mode_dict[v.name] - hybrid_mode_test_list.append([v.name, v.status,mode_status]) - headers = ['Testcase_name', 'Status','Testcase_mode'] - self.tabulate_result = tabulate(hybrid_mode_test_list, headers=headers[:], tablefmt='grid') - terminalreporter.write_line(self.tabulate_result) - self.dump_hybrid_mode_report() + terminalreporter.write_line("\n TestCase Summary Status Table") + hybrid_mode_test_list = [] + hybrid_mode_dict=self.hybrid_mode_status_dict + mode_status="" + for k,v in self.testcase_dict.items(): + if v.name in hybrid_mode_dict.keys(): + mode_status=hybrid_mode_dict[v.name] + hybrid_mode_test_list.append([v.name, v.status,mode_status]) + headers = ['Testcase_name', 'Status','Testcase_mode'] + self.tabulate_result = tabulate(hybrid_mode_test_list, headers=headers[:], tablefmt='grid') + terminalreporter.write_line(self.tabulate_result) + self.dump_hybrid_mode_report() else: - terminalreporter.write_line("\n TestCase Summary Status Table") - temp_list = [] - - for k,v in self.testcase_dict.items(): - try: - message = v.message.chain[0][1].message - except: - message = v.message - temp_list.append((v.name, v.status)) - headers = ['Testcase_name', 'Status'] - self.tabulate_result = tabulate(temp_list, headers=headers[:], tablefmt='grid') - terminalreporter.write_line(self.tabulate_result) + terminalreporter.write_line("\n TestCase Summary Status Table") + + if self.no_detail_message: + headers = ['Testcase_name', 'Status'] + temp_list = [(v.name, v.status) for v in self.testcase_dict.values()] + else: + headers = ['Testcase_name', 'Status', "Message"] + temp_list = [] + for k,v in self.testcase_dict.items(): + try: + message = v.message.chain[0][1].message + except Exception: + message = v.message + # Ensure the message isn't too long, truncating if necessary. + if isinstance(message, str) and len(message) > 100: + message = message[:100] + " ..." + temp_list.append((v.name, v.status, message)) + + self.tabulate_result = tabulate(temp_list, headers=headers, tablefmt='grid') + terminalreporter.write_line(self.tabulate_result) self.dump_model_coverage_report() terminalreporter.write_line("Results: {work_dir}".format(work_dir=CafyLog.work_dir)) terminalreporter.write_line("Reports: {allure_html_report}".format(allure_html_report=self.allure_html_report)) From 2ec4301b4d2c34459cf6f7713a8a5a21d5ec03ad Mon Sep 17 00:00:00 2001 From: Lewis Gaul Date: Wed, 17 May 2023 15:39:35 -0700 Subject: [PATCH 2/2] Use dict.values() since the keys aren't used --- cafy_pytest/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cafy_pytest/plugin.py b/cafy_pytest/plugin.py index ca49b6e..9ad47d2 100644 --- a/cafy_pytest/plugin.py +++ b/cafy_pytest/plugin.py @@ -1830,7 +1830,7 @@ def pytest_terminal_summary(self, terminalreporter): else: headers = ['Testcase_name', 'Status', "Message"] temp_list = [] - for k,v in self.testcase_dict.items(): + for v in self.testcase_dict.values(): try: message = v.message.chain[0][1].message except Exception: