I am new to pytest frame work and trying to understand pytest hooks. I have placed some print statements in pytest hooks but not sure about how i can print the statement on console. Here is the example that i tried
# content of conftest.py
import pytest
import sys
def pytest_load_initial_conftests(args):
print ("Hello")
if 'xdist' in sys.modules: # pytest-xdist plugin
import multiprocessing
num = max(multiprocessing.cpu_count() / 2, 1)
args[:] = ["-n", str(num)] + args
print ("args: ", args)
# content of the test_sample.py
def test_answer():
# assert 0
print ("test function")
pass
I have tried using pytest test_sample.py -s, pytest --capture=sys/fd/no. I could only obtain print statement on console from the test_answer function but not from the pytest hook.
Thanks