I must run the script below by hand $ python -m mylog
in order to test logging.
Why does $ pytest -s
fail creating the logfile?
#mylog.pyimport loggingdef foobar(logfile): logging.basicConfig(filename=logfile, level=logging.DEBUG) logging.debug('This message should go to the log file') logging.info('So should this') logging.warning('And this, too') logging.error('And non-ASCII stuff, too, like Øresund and Malmö')
#test_mylog.pyfrom . import mylogfrom pathlib import Pathdef test_mylog(): logfile='./mylog.log' mylog.foobar(logfile) assert Path(logfile).exists()
>>> AssertionError: assert False