Replies: 1 comment
|
Hi @ws1088 What you are seeing is consistent with pytest's execution order. With a yield fixture: setup
yield
teardownpytest runs the test call after the So if your fixture redirects the process's stdout/file descriptor across the entire can be written while that redirection is still active. By the time the fixture restores stdout in teardown, the progress character has already gone to your file. The fix is not to hold a global stdout/stderr redirection open across the entire pytest test lifecycle. Prefer one of:
A fixture finalizer cannot restore the descriptor before pytest reports the test call because teardown happens afterward. Please mark this answer as accepted if it helped, thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Hi all,
It looks like a function scope fixture is torn down after the printing of
.in the console. I am writing a fixture which capture stdout/stderr to a file and it is capturing�[32m.�[0mbeforeprint('hello'):test-specific file content:
Am I doing anything wrong?
Thanks in advance.
All reactions