I'm using pytest to do unit testing. I have the logging code on the top of the calc_test.py source code:
module_logger = logging.getLogger(__name__)
module_logger.warning(f"Start module:{__name__}, the source file: {__file__}")
I expect that every time I run pytest -vv -s calc_test.py, the above logging info would show near the very beginning of the logs.
To my surprise, this logging never shows up. Even the loggings in conftest.py were successfully shown.
I dug into the official documentation, to find any explantion of the execution order for each test file. However there is no mentioning of the loggings at the beginning of each file. My guess is that pytest will put on hold each testing files and first run all the stuff in conftest.py. But this isn't confirmed by the documentation.
Very weird, could you explain this behavior?
--log-cli-level=WARNING. - MrBean Bremenlive logssection, but it doesn't seems to be the cause. And I already am using thewarninglevel. I guess it might has something to do with the location of thisconftest.pyresiding inside a package, where the__init__.pymust be loaded first. I'll keep digging... - Jinghui Niu--log-cli-level(or the respective setting in pytest.ini) nothing will be logged forloggingcalls.-sis only to show stdout. - MrBean Bremen