Hi Holger, On Sun, Sep 30, 2012 at 9:56 PM, holger krekel <hol...@merlinux.eu> wrote: > Hi Anton, > > On Sun, Sep 30, 2012 at 19:16 +0300, Anton P wrote: >> Hi All, >> >> I'd like to use standard logging module with py.test. Messages >> generated from test functions are visible on stdout if -s option is >> set. But log messages generated from conftest.py or other custom >> modules used inside test function are not visible on stdout but >> visible in captured stdout in case -s option isn't set. >> >> I want to see all the messages from all modules on stdout, not only >> from test function. > > An initial conftest.py file is loaded very early and pytest uses > unconditional capturing. This goes back to a request from the PyPy > folks who start GCC at this stage and otherwise see lots of stuff. > If this proves to be a problem we have to see how to make it conditional. > Problem is that the conftest.py often add command line options and thus > need to to be loaded before opts are parsed (and thus "-s"). > If logging is active during conftest.py import-time it will see the > captured stream and probably record it and use it from there on. > As the captured stream is not analyzed/used further in the case of "-s" > it is kind of lost, loosing the logging messages. > > Potential solutions: > > - try to avoid doing calls/imports of logging during conftest.py import-time. > - try out pytest-logging plugin to see if it helps > - program a PYTEST_NOCAPTURE environement setting to pytest to allow switching > off capturing totally > > best, > holger > > That >> Thank you in advance! >> -Anton >> _______________________________________________ >> py-dev mailing list >> py-dev@codespeak.net >> http://codespeak.net/mailman/listinfo/py-dev >>
Thank you for the answer. Your clarification in py.test capture functionality helped me to resolve my issue. So if I init logger on function level instead module level as before, I get all messages on console. In case module is imported only in test functions (not in conftest), I can init logger on module level. This is acceptable for me. BTW I forgot to write that file handler of standart python logging module works properly. The issue only with stdout logging. -Anton _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev