My testing framework has below structure
I have logging enabled in pytest.ini for INFO
[pytest]
log_cli = 1
log_cli_level = INFO
Below is my code in conftest.py
def pytest_generate_tests(metafunc):
.....
logging.info("This is generated during the test collection !!!")
When i run the test either of the test files, logs are printed 2 times once in the formatting specified in pytest.ini and another in red color
pytest -s Test_Reg1.py
I am so lost why is the logging info getting printed twice.
If you want to see only the output of logging module, use --log-cli-level=INFO
as an argument to pytest test run. You are seeing it twice because of -s
switch. And, to test whether it's the same log or different, add timestamp to the log message.