Add test around nested captures

This commit is contained in:
Darren Burns 2022-06-29 14:53:44 +01:00
parent 6e7074b4cb
commit 55b562ccdd
No known key found for this signature in database
GPG Key ID: B0939B45037DC345
1 changed files with 14 additions and 0 deletions

View File

@ -381,6 +381,20 @@ def test_capture_echo_outputs_captured_content_to_terminal(capsys):
assert out == "1\n2\n3\n" assert out == "1\n2\n3\n"
def test_capture_echo_nested_capture():
# TODO: This behaviour doesn't seem correct
console = Console()
console.print(1)
with console.capture() as capture1:
console.print(2)
with console.capture() as capture2:
console.print(3)
console.print(4)
assert capture1.get() == ""
assert capture2.get() == "2\n3\n"
def test_input(monkeypatch, capsys): def test_input(monkeypatch, capsys):
def fake_input(prompt=""): def fake_input(prompt=""):
console.file.write(prompt) console.file.write(prompt)