Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable per test "dots" while pytest-ing [duplicate]

I have parametrized test suite with ~10^5 tests. And I'm debugging raised errors consequently, I.e using -x flag. Like so:

pytest tests.py -x

Problem here is that this command cluttering terminal with . corresponding to each test. Which is not desired (cause I have no any xfaild or something - only passed or not; and due to the number of tests):

............................................................................................................................................................................................................ [  5%]
............................................................................................................................................................................................................ [ 11%]
............................................................................................................................................................................................................ [ 17%]

How to disable this "dots" and left only progress bar? Maybe some plugin? Tried -q but dots still printing.

like image 697
BeforeFlight Avatar asked Sep 15 '25 09:09

BeforeFlight


1 Answers

You could implement the pytest_report_teststatus() hook in your conftest.py. It returns a tuple result-category, shortletter and verbose word.

def pytest_report_teststatus(report, config):
    if report.passed and report.when == "call":
        return report.outcome, "", report.outcome.upper()

The hook is called 3 times for each test, with report.when set to "setup", "call" or "teardown". The callback above sets the shortletter to an empty string if the test passes in the "call" phase.

like image 70
Alexander Fasching Avatar answered Sep 17 '25 21:09

Alexander Fasching



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!