A plugin for defining your own characters to be used when displaying test outcomes in pytest (passed, failed, skipped etc).
For example, if you wanted to see a PILE OF POO (U+1F4A9) glyph displayed in the terminal report for each failing test:
pytest --report-failed=💩
To persist your custom characters, add a section like this in the configuration file (i.e. in pytest.ini
, tox.ini
, setup.cfg
or whatever):
[pytest] report_failed = 💩 report_failed_verbose = OH CRAP
pip install pytest-custom-report
This will add new command-line arguments and configuration file options to pytest
(detailed in the following section). Command line arguments take precedence over configuration file settings. The plugin is always enabled, but unless you've configured your own symbols the pytest
defaults are used.
To execute tests with the plugin disabled temporarily, use this:
pytest -p no:pytest-custom-report
If you're trying to use emojis but you can't see the glyphs properly in your terminal, you may be missing unicode fonts with the upper plane - you could install for example GNU Unifont.
The table below shows the available options as well as pytest
's default style for each outcome.
test outcome | command-line argument name | .ini file config key | default report symbol |
---|---|---|---|
passed |
--report-passed |
report_passed |
. |
xpassed |
--report-xpassed |
report_xpassed |
X |
failed |
--report-failed |
report_failed |
F |
xfailed |
--report-xfailed |
report_xfailed |
x |
skipped |
--report-skipped |
report_skipped |
s |
error |
--report-error |
report_error |
E |
When tests are executed with -v
or --verbose
flag enabled, you'll see longer strings displayed and one-line per test outcome. These can be specified too.
test outcome | command-line argument name | .ini file config key | default report string |
---|---|---|---|
passed |
--report-passed-verbose |
report_passed_verbose |
PASSED |
xpassed |
--report-xpassed-verbose |
report_xpassed_verbose |
XPASS |
failed |
--report-failed-verbose |
report_failed_verbose |
FAILED |
xfailed |
--report-xfailed-verbose |
report_xfailed_verbose |
XFAIL |
skipped |
--report-skipped-verbose |
report_skipped_verbose |
SKIPPED |
error |
--report-error-verbose |
report_error_verbose |
ERROR |
Here is some example pytest.ini
content that you can copy-paste and modify to your liking:
[pytest] report_passed = ✔ report_xpassed = 🦄 report_failed = ✗ report_xfailed = 👎 report_skipped = ? report_error = 🔥 report_passed_verbose = OH YEAH report_xpassed_verbose = WHAT IN TARNATION? report_failed_verbose = OH CRAP report_xfailed_verbose = YEAH WHATEVER report_skipped_verbose = DON'T CARE report_error_verbose = YOU MEDDLING KIDS!