I have the following python file fct.py. If I run test1() or test2() directly in python or ipython, I get:
In [315]: test1()
fct - fct.py[line:9] 2017-01-02 17:23:22,992 : DEBUG : debug output
In [316]: test2()
fct - fct.py[line:9] 2017-01-02 17:23:26,393 : DEBUG : debug output
If I run
nosetests -v fct.py
I get:
test1 logging ... ok
test2 logging ... ok
Ran 2 tests in 0.000s
OK
No logging output "debug output".
How do I obtain the logging message "debug output" in nosetests? I read nosetests -h and google around a bit but can't seem to find a solution. Thanks for any help or pointers.
''' fct.py '''
import logging
LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())
def fct():
''' fct logging '''
LOGGER.debug(" debug output")
def test1():
''' test1 logging '''
fct()
assert 1==1
def test2():
''' test2 logging '''
logging.basicConfig(level=logging.DEBUG)
fct()
assert 1==1
nosetests --nologcapture fct.py
will do the trick