Most of the time when I'm using pytest, the output is very, very long. More than a hundred lines. And often times I want this output, I really do. --tb=short
isn't really a very good approach. But I don't want to have to scroll back 200 lines in my tmux window to find my test output because that's also super annoying.
What I would love to have is something like this:
______________________ >>test_my_test_with_a_lot_of_output _______________________
# imagine lots of test output here
______________________ <<test_my_test_with_a_lot_of_output _______________________
Is there some flag or setting I can use in py.test to achieve this kind of output?
Pytest automatically identifies those files as test files. We can make pytest run other filenames by explicitly mentioning them. Pytest requires the test function names to start with test. Function names which are not of format test* are not considered as test functions by pytest.
Running pytest We can run a specific test file by giving its name as an argument. A specific function can be run by providing its name after the :: characters. Markers can be used to group tests. A marked grouped of tests is then run with pytest -m .
To generate HTML reports with the Pytest framework we have to install a plugin. For the installation, we shall execute the command pip install pytest-html. Next to generate the report we shall run the command pytest –html=report. html.
Additionally, if you wish to display a list of fixtures for each test, try the --fixtures-per-test flag.
Use "pytest -rA" when running tests
see docs here
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