From 32c4f7e4ad3d5859386632bd91f1c8781820d71c Mon Sep 17 00:00:00 2001 From: liquidsec Date: Mon, 28 Oct 2024 10:23:42 -0400 Subject: [PATCH] fixing pytest summary --- bbot/test/conftest.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bbot/test/conftest.py b/bbot/test/conftest.py index 516c0fec2..b62da9edb 100644 --- a/bbot/test/conftest.py +++ b/bbot/test/conftest.py @@ -216,20 +216,20 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config): # pragma: no errors = len(stats.get("error", [])) failed = stats.get("failed", []) - print("\nTest Session Summary:") - print(f"Total tests run: {total_tests}") - print( - f"{GREEN}Passed: {passed}{RESET}, {RED}Failed: {len(failed)}{RESET}, {YELLOW}Skipped: {skipped}{RESET}, Errors: {errors}" + terminalreporter.write("\nTest Session Summary:") + terminalreporter.write(f"\nTotal tests run: {total_tests}") + terminalreporter.write( + f"\n{GREEN}Passed: {passed}{RESET}, {RED}Failed: {len(failed)}{RESET}, {YELLOW}Skipped: {skipped}{RESET}, Errors: {errors}" ) if failed: - print(f"\n{RED}Detailed failed test report:{RESET}") + terminalreporter.write(f"\n{RED}Detailed failed test report:{RESET}") for item in failed: test_name = item.nodeid.split("::")[-1] if "::" in item.nodeid else item.nodeid file_and_line = f"{item.location[0]}:{item.location[1]}" # File path and line number - print(f"{BLUE}Test Name: {test_name}{RESET} {CYAN}({file_and_line}){RESET}") - print(f"{RED}Location: {item.nodeid} at {item.location[0]}:{item.location[1]}{RESET}") - print(f"{RED}Failure details:\n{item.longreprtext}{RESET}") + terminalreporter.write(f"\n{BLUE}Test Name: {test_name}{RESET} {CYAN}({file_and_line}){RESET}") + terminalreporter.write(f"\n{RED}Location: {item.nodeid} at {item.location[0]}:{item.location[1]}{RESET}") + terminalreporter.write(f"\n{RED}Failure details:\n{item.longreprtext}{RESET}") # BELOW: debugging for frozen/hung tests