Previously, we consider how to test print output using pytest. This is a continuation which considers how to test logged output. For printed output, we used pytest‘s capsys fixture to grab the stdout (quite useful) and stderr (unclear utility?). capsys doesn’t provide a mechanism to tap into the logging stream. So, what should we use…
Category: testing
Testing Printed Output using `pytest`
While typically testing focuses on evaluating the output of a function (i.e., what it returns) or the state of an object at a particular point in time, there are occasions when it can be important to test the printed or logged output. This might include warnings about module, parameter, or function deprecation; messages about problematic…