nicoddemus / pytest-rich

pytest + rich integration (proof of concept)
MIT License
220 stars 18 forks source link

Failures during test collection aren't shown #75

Open edmorley opened 1 year ago

edmorley commented 1 year ago

If I make a Python syntax error in a test, or one of the project files imported by one of the tests, with stock pytest, I get an error like:

$ pytest
====================================== test session starts =======================================
platform darwin -- Python 3.11.0, pytest-7.2.0, pluggy-1.0.0
rootdir: /Users/<snip>, configfile: pyproject.toml, testpaths: tests
plugins: anyio-3.6.2
collected 0 items / 2 errors                                                                     

============================================= ERRORS =============================================
_______________________________ ERROR collecting tests/test_cli.py _______________________________
ImportError while importing test module '<snip>/tests/test_cli.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
<snip>
=====================================
ERROR tests/test_cli.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================= 2 errors in 0.14s ========================================

However with pytest-rich installed and using pytest run using --rich, these errors are hidden:

$ pytest --rich
────────────────────────────────────────────── pytest session starts ──────────────────────────────────────────────
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ platform darwin pytest 7.2.0 python 3.11.0                                                                      │
│ root /Users/<snip>                                                                                              │
│ plugins rich-0.1.2.dev26+gaea02fb, anyio-3.6.2                                                                  │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Collected 0 items

╭──── Summary ─────╮
│  0  Total        │
│     Tests        │
╰──────────────────╯
───────────────────────────────────────────── FAILED in 0.00 seconds ──────────────────────────────────────────────

This was using the latest development version of pytest-rich (currently aea02fbe1e8dc85d7216e343ec52d06244ddc8c9).

joshuadavidthomas commented 1 year ago

Thanks for taking the time to submit this detailed issue @edmorley!