9

I want to completely custom tests results output. In unittest I can implement my own test runner by example of unittest.TextTestRunner. How can I do the same in pytest?

1
  • Take a look at how pytest-custom-report plugin does it for inspiration. Commented Jun 6, 2024 at 4:43

1 Answer 1

4

As described in "Writing plugins" section of pytest documentation, you'll need to work with pytest hooks:

pytest implements all aspects of configuration, collection, running and reporting by calling well specified hooks of the following plugins:

Also see:

Sign up to request clarification or add additional context in comments.

3 Comments

Seems like hooks allows to just modify information that will be represented in some standard way, but how to completely redesign results report? For example I want to write it to CSV?
Yeah, that's not like a simple task to do with pytest. Have you considered using nose?
Gill, that's certainly possible, as far as I know. For an example, look at Mozilla Web QA's pytest module, which formats reports as HTML. A lot of the logic would be the same as formatting them as CSV (though IMO using standard JUnit XML would be a lot better...) github.com/davehunt/pytest-mozwebqa/tree/master/pytest_mozwebqa

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.