How can I get expandable output from PyTest
?
For example the local variables. It would be great if I could expand/collapse them depending on my need.
I think that's where the current text-output of PyTest
reaches its limit.
The question: Is there a way to get an interactive output from PyTest
?
With interactive I mean to be able to expand/collapse the local variables.
Above example is from the django debug page.
I would like to have such an interactive output if I run pytest.
My output looks like this:
For achieving an output similar to the screenshot (which I assume is from a Django debugging session), you will need pytest and the pytest-html plugin.
You invoke pytest using this command line.
pytest --showlocals --html=report.html --self-contained-html testmodule/test.py
This will give you a HTML report with a nice overview of collapsible tests. Passing the argument --showlocals
will also be reflected in the HTML report. All failed tests will show the local variable scope.
I created a small example repository with further instructions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With