Skip to content
Myr

Force virtual terminal width in tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 1a5b4e7 · Browse files · 4 files+18 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+18 added−2 removed

  • other:+18 added−2 removed

4 files+18 added−2 removed

modified:click/_unicodefun.py+7 added-1 removed
1import os2import sys3import codecs45import click5from ._compat import PY2678# If someone wants to vendor click, we want to ensure the9# correct package is discovered. Ideally we could use a10# relative import here but unfortunately Python does not11# support that.12click = sys.modules[__name__.rsplit('.', 1)[0]]131415def _find_unicode_literals_frame():16 import __future__17 frm = sys._getframe(1)18 idx = 1
96 unmodified lines
modified:click/formatting.py+7 added-1 removed
2 unmodified lines
3from .parser import split_opt4from ._compat import term_len567# Can force a width. This is used by the test system8FORCED_WIDTH = None91011def measure_table(rows):12 widths = {}13 for row in rows:14 for idx, col in enumerate(row):
87 unmodified lines
102 self.indent_increment = indent_increment103 if max_width is None:104 max_width = 80105 if width is None:106 width = FORCED_WIDTH107 if width is None:102 width = max(min(get_terminal_size()[0], max_width) - 2, 50)108 width = max(min(get_terminal_size()[0], max_width) - 2, 50)109 self.width = width110 self.current_indent = 0111 self.buffer = []112
144 unmodified lines
modified:click/testing.py+3 added
155 unmodified lines
156157 old_stdin = sys.stdin158 old_stdout = sys.stdout159 old_stderr = sys.stderr160 old_forced_width = clickpkg.formatting.FORCED_WIDTH161 clickpkg.formatting.FORCED_WIDTH = 80162163 env = self.make_env(env)164165 if PY2:
71 unmodified lines
237 clickpkg.termui.visible_prompt_func = old_visible_prompt_func238 clickpkg.termui.hidden_prompt_func = old_hidden_prompt_func239 clickpkg.termui._getchar = old__getchar_func240 clickpkg.utils.should_strip_ansi = old_should_strip_ansi241 clickpkg.formatting.FORCED_WIDTH = old_forced_width242243 def invoke(self, cli, args=None, input=None, env=None,244 catch_exceptions=True, color=False, **extra):245 """Invokes a command in an isolated environment. The arguments are
77 unmodified lines
modified:CHANGES+1 added
31 unmodified lines
32- For users running Python 2 the echo() and prompt() functions now work33 with unicode in the Python windows console. For Python 3 the work34 is delegated to the Python interpreter as general support for Unicode35 in the console is implemented to some degree.36- Unittests now always force a certain virtual terminal width.3738Version 5.139-----------40
251 unmodified lines