2

I've read the various questions about pytest-catchlog etc but I'm none the wiser - how exactly does Pytest do logging?

I have a top-level Python app that creates a log file. There are a number of modules used by the app and their logging also ends up in the log file. But I want to unit test these modules and when I write a Pytest unit test and run it, there is no logging anywhere from the modules.

I've seen talk about 'pytest-catchlog' but it talks about stdout and the like and I don't even see my logs appearing on screen. So how is Pytest generating (or not) logs and how can I tap in and get the log file that I want?

2
  • 1
    have you tried the options -vv and -s to increase the verbosity and capture logs. pytest-capture Commented May 31, 2017 at 9:39
  • Thanks - what has been confusing me was that '-s' is about stdout and I've only ever seen logging to files. However having now figured out that logging can also be a glorified print(), I've managed to see what is happening. It seems that whoever wrote the product that I've inherited wrote their own logging code in a very odd manner and apparently that's been totally sabotaging my attempts to use logging. So a combination of improving this strange code and your -s/-vv suggestions is starting to yield results. Thanks. Commented Jun 2, 2017 at 9:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.