pytest-dev / pytest-dev/pytest
pytest to be completely quiet when asked
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
What's the problem this feature will solve?
There currently seems to be no easy way to make pytest not produce any output when all tests pass.
pytest --quiet --quiet ... fails to do what seems to be the most expected thing -- be quiet, still printing dots and progress information:
$ pytest --quiet --quiet
....... [100%]
-o console_output_style=none silences the progress and the dots can be dealt with with a pytest_report_teststatus() hook, but:
- the
noneonly works because it's not one of the officially supported values forconsole_output_styleand the code doesn't bother raising an error, - more importantly, using the option and the hook feels more work than what making pytest quiet should take and
- crucially, even using the option and the hook pytest still emits an empty line.
The new line character seems to come from pytest_sessionfinish():
@hookimpl(wrapper=True)
def pytest_sessionfinish(
self, session: Session, exitstatus: int | ExitCode
) -> Generator[None]:
result = yield
self._tw.line("") # HERE
Describe the solution you'd like
I would expect pytest to support a command-line option or a set of options that together would make it not produce any output unless a test is failed.
Something like:
pytest --quiet --quiet --quiet ...
pytest --really-quiet ...
pytest --no-report-on-success ...
Alternative Solutions
Running chronic pytest ... helps, but prevents colour output.
Additional context
None.
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 reproducing the issue with pytest --quiet --quiet, then inspect the pytest_sessionfinish() hook and handling of console_output_style. Define the behavior for a successful run and verify that the chosen option or options suppress dots, progress output, and the trailing empty line while preserving output for failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100