ApprovalTests.Python
ApprovalTests.Python copied to clipboard
Can't verify logs and function output at the same time
I tried verify_logging
and it doesn't quite work as expected in this scenario. i want a separate output file for logging, and another one for function return
def fizzbuzz(n):
out_str = "\n".join(map(lambda n: fizzbuzz_single(n), range(1, n)))
logging.info(f"Fizzbuss log says {out_str}")
return out_str
def test_fizzbuzz_ten():
with verify_logging():
verify(fizzbuzz(10) )
suggested solution is to have two separate output files - one for logs, one for output. Some kind of NamerFactory
Would expect test_fizzbuzz_ten.logging.approved.txt in addition test_fizzbuzz_ten.approved.txt
There are two verifies happening and if one fails the test should fail and we would need to indicate why
here are three solutions: https://github.com/approvals/ApprovalTests.Python/blob/main/docs/how_to/verify_both_logs_and_results.md
We want this to not be confusing and we know people get confused by when and how to use multiple verifies in a single test. A warning might be helpful, especially if you are attempting to compare against the same file multiple times in one test