fix input on legacy windows

This commit is contained in:
Will McGugan 2020-10-19 16:41:15 +01:00
parent 35e09d4701
commit 9f2a426ea7
4 changed files with 43 additions and 0 deletions

View file

@ -191,6 +191,18 @@ def test_input(monkeypatch, capsys):
assert user_input == "bar"
def test_input_legacy_windows(monkeypatch, capsys):
def fake_input(prompt):
console.file.write(prompt)
return "bar"
monkeypatch.setattr("builtins.input", fake_input)
console = Console(legacy_windows=True)
user_input = console.input(prompt="foo:")
assert capsys.readouterr().out == "foo:"
assert user_input == "bar"
def test_input_password(monkeypatch, capsys):
def fake_input(prompt, stream=None):
console.file.write(prompt)
@ -380,6 +392,20 @@ def test_out() -> None:
assert console.end_capture() == "foo bar.foo bar.foo bar.foo bar.foo barX"
def test_render_group() -> None:
@render_group(fit=False)
def renderable():
yield "one"
yield "two"
yield "three" # <- largest width of 5
yield "four"
renderables = [renderable() for _ in range(4)]
console = Console(width=42)
min_width, _ = measure_renderables(console, renderables, 42)
assert min_width == 42
def test_render_group_fit() -> None:
@render_group()
def renderable():