'Is there a way in pytest to get rid of the "x tests ran in 0.01s" line in the output?

I have a usecase in which I use pytest to go over each file and just collect some metadata specific for my tests. I would like to use the output in another tool without having to manually remove the === no tests ran in 0.10s === line from the bottom of the output.

I have tried adding multiple quiet options and --no-summary but neither of them removes this.

I have noticed that if i use --collect-only with -qq this makes it disappear. I thought I could just use this but reading through documentation I haven't found a way to trigger the collect-only behavior other than using:

def pytest_configure(config) -> None:
    if config.option.collect_metadata:
        config.addinivalue_line("addopts", "--collect-only")

but that doesn't seem to work either.

Is there a way to get rid of all the summary lines including === no tests ran in 0.10s === without writing my own test collector?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source