pytest does not capture print() statements (stdout output) which are located in pytest_sessionfinish() or code which is called in there. What's best practice to get same or similar behavior like print() statements located in tests, fixtures, etc.?
# conftest.py
def pytest_sessionfinish(session, exitstatus):
print('This wont be captured (like in tests) but output independent of pytest exit status (exitstatus).')
if exitstatus == 0:
print('stdout shall be captured/suppressed in case of overall test PASS.')
else:
print('stdout shall be output in case of overall test FAIL and any other error.')