mirror of
https://github.com/Textualize/rich.git
synced 2025-08-10 04:58:07 +00:00
fix input on legacy windows
This commit is contained in:
parent
35e09d4701
commit
9f2a426ea7
4 changed files with 43 additions and 0 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue