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
Provenance
- Commit
5112cf9- Tree
297afc9- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
1a5b4e7
4 files changed+18 added−2 removed
modified:click/_unicodefun.py+7 added-1 removed
1 import os2 import sys3 import codecs4 5-import click5 from ._compat import PY26 7 8+# 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.12+click = sys.modules[__name__.rsplit('.', 1)[0]]13+14+15 def _find_unicode_literals_frame():16 import __future__17 frm = sys._getframe(1)18 idx = 196 unmodified linesmodified:click/formatting.py+7 added-1 removed
2 unmodified lines3 from .parser import split_opt4 from ._compat import term_len5 6 7+# Can force a width. This is used by the test system8+FORCED_WIDTH = None9+10+11 def measure_table(rows):12 widths = {}13 for row in rows:14 for idx, col in enumerate(row):87 unmodified lines102 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 linesmodified:click/testing.py+3 added
155 unmodified lines156 157 old_stdin = sys.stdin158 old_stdout = sys.stdout159 old_stderr = sys.stderr160+ old_forced_width = clickpkg.formatting.FORCED_WIDTH161+ clickpkg.formatting.FORCED_WIDTH = 80162 163 env = self.make_env(env)164 165 if PY2:71 unmodified lines237 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_width242 243 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 are77 unmodified linesmodified:CHANGES+1 added
31 unmodified lines32 - 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.37 38 Version 5.139 -----------40 251 unmodified lines