pallets / pallets/click

Testing output is dependent on terminal width

Open
#1,997 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

test runner
Dominant language
Python
Stars
17.7k
Forks
2.3k
Avg merge
1d 30m
Merged PRs (30d)
18

Description

After https://github.com/pallets/click/pull/1829, while using

        runner = CliRunner()
        result = runner.invoke(...)

result.output contains the newline introduced by the wrappings due to auto detected terminal width. This is undesirable in test cases. As the docs says that these tools are made for testing only, IMO it would be better if the terminal width wrapping could be avoided in the output.
For now, I'm using runner.invoke(terminal_width=1000, ...) in my test cases. Maybe having terminal_width=0 or a negative number could be treated an infinitely large terminal.

Environment:

  • Python version: Python 3.9.5
  • Click version: click==8.0.1

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 at CliRunner.invoke and its terminal_width handling, using the reported runner.invoke example to reproduce output wrapping. Check how terminal width is detected and test the proposed behavior for an unbounded width; done means test output no longer gains wrapping newlines in that mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.