I would like to put some logging statements within test function to examine some state variables.
I have the following code snippet:
import pytest,os
i
Works for me, here's the output I get: [snip -> example was incorrect]
Edit: It seems that you have to pass the -s option to py.test so it won't capture stdout. Here (py.test not installed), it was enough to use python pytest.py -s pyt.py.
For your code, all you need is to pass -s in args to main:
pytest.main(args=['-s', os.path.abspath(__file__)])
See the py.test documentation on capturing output.