pytest-dev / pytest-dev/pytest

pytest to be completely quiet when asked

Open
#13,224 8 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: reporting type: proposal
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 none only works because it's not one of the officially supported values for console_output_style and 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.