Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14126

What is the type hint for Pytest's "caplog" fixture?

$
0
0

I am using the caplog fixture that comes with pytest. I am using mypy for my type checking, and would like to know what the correct type hint for caplog is.

For example:

def test_validate_regs(caplog: Any) -> None:    validate_regs(df, logger)    assert caplog.text == "", "No logs should have been made."

In this example, I have it set to Any, but I am wondering if there is a more specific type hint I can use.

I've tried reading the docs on caplog, as well as searching the pytest code in github to see what the caplog fixture returns, but couldn't find anything more than the following. But using a str type just gave me an error, saying that str type doesn't have the attribute text, which makes sense.

When I print the type of caplog I get _pytest.logging.LogCaptureFixture although I'm not sure how I'd import this from _pytest and make use of it.


Viewing all articles
Browse latest Browse all 14126

Trending Articles