From 55b562ccdd4b5833dcd9713d5fae61baac3bdc57 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Wed, 29 Jun 2022 14:53:44 +0100 Subject: [PATCH] Add test around nested captures --- tests/test_console.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_console.py b/tests/test_console.py index cdd30062..332b0a04 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -381,6 +381,20 @@ def test_capture_echo_outputs_captured_content_to_terminal(capsys): 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 fake_input(prompt=""): console.file.write(prompt)