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.')
5 Related questions 255 Logging within pytest tests 856 How to see normal print output created during pytest run? 3 pytest capturing all output to stdout Related questions 255 Logging within pytest tests 856 How to see normal print output created during pytest run? 3 pytest capturing all output to stdout 3 Access pytest session or arguments in pytest_runtest_logreport 6 pytest option to output print/logging statements from tested code 3 pytest_sessionstart/finish won't print 2 passing variable to pytest_sessionfinish 2 How to capture print statements inside pytest hooks 2 Pytest capture stdout of a certain test 1 pytest_sessionstart/finish show AttributeError: 'Session' object has no attribute 'results' Load 7 more related questions Show fewer related questionsSorted by: Reset to defaultKnow someone who can answer? Share a link to this question via email, Twitter, or Facebook.
ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobGpvaGiDd4COoaawZaSkeqStz62sq51dpb%2BqutNmqq2ZpJq6prrTrGSipl2lxrWx0q1krJ2jqLawusWipaKrmA%3D%3D