pytest won't show me the logger records that occur during testing. Checked that logging is enabled in config and that level is DEBUG
, added log_cli = 1
to pytest.ini, still doesn't work.
It captures stdout and stderr just fine, so usual print()
s are displayed.
Tried running with -r a
as advised here, to no avail.
Added caplog
to my test, caplog.records
is []
.
I know that code gets to the log emission point (through the use of prints).
EDIT: minimal reproducible examples:
class TestLogging:
def test_logging(self):
from app import logger
logger.error("log test") # nothing shows up
print("print test") # prints as expected
assert False
def test_caplog(self, caplog):
from app import logger
logger.error("log test") # nothing shows up
print(caplog.records) # prints '[]'
assert False
Running with
FLASK_ENV=testing pipenv run pytest controller/tests/test_user_routes.py -k test_logging
and
FLASK_ENV=testing pipenv run pytest controller/tests/test_user_routes.py -k test_caplog
EDIT2: settings and how logger is set up: https://pastebin.com/EG8g90m5