pytest-dev / pytest-dev/pytest
Implement a `rich`-based `TerminalReporter`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
At the pytest sprint, we discussed making pytest's output more modern (and digestable), drawing inspirations from projects such as:
However, at least for a first step, we want to keep the output similar "in spirit" to what it is now, perhaps with minor improvements like using unicode (if available) to draw lines instead of the current ASCII-based lines.
To do so, we want to drop our custom terminal formatting code in the long run and switch to rich. However, such a switch might be problematic, especially given that rich also uses pytest (and if they break something, they might be unable to run their testsuite). Then again, we depend on pygments and colorama and that has never been much of a problem.
To ease into this, we discussed about the following approach:
- Have
richas an optional dependency (sadly we don't have default extras quite yet), and have a second internalterminalreporterplugin that takes over (and uses rich for output) if it is installed. It should replicate the current output to a high degree, but based on rich. - At some point, make the new
richterminal reporter the default, and addrichas a hard dependency for pytest - Perhaps add a fallback mode if something goes wrong with rich, where pytest shows barebones output and a warning (no lines etc., but still enough to use it if absolutely required)
- Decide what to do with the low-level
TerminalWriter. We might still want to keep it as a thin shim around rich. It seems to be private API, however (pytest_terminal_summarygetsterminalreporter, andTerminalReporterhas a private_twobject).
cc @willmcgugan as a heads-up
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing TerminalReporter and the private TerminalWriter (_tw), along with the pytest_terminal_summary entry point. Define how an optional rich-based reporter should preserve current output and how it should interact with rich's optional installation; done requires a working reporter that closely replicates existing output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100