See the py.test documentation on capturing output. Here (py.test not installed), it was enough to use python pytest.py -s pyt.py.įor your code, all you need is to pass -s in args to main: pytest.main(args=) Works for me, here’s the output I get: Įdit: It seems that you have to pass the -s option to py.test so it won’t capture stdout. Is there a way to force pytest to emit logging to console from test methods as well? How to solve the problem: Solution 1: Notice that only the logging messages from the ‘_name_ = _main_’ block get transmitted to the console. Platform darwin - Python 2.6.2 - pytest-2.0.0 I get the following output: python minitest.py I have the following code snippet: import pytest,os I would like to put some logging statements within test function to examine some state variables. Question or problem about Python programming:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |