def test_capture_and_record() -> None:
    """Regression test for https://github.com/Textualize/rich/issues/2563"""

    console = Console(record=True)
    print("Before Capture started:")
    console.print("[blue underline]Print 0")
    with console.capture() as capture:
        console.print("[blue underline]Print 1")
        console.print("[blue underline]Print 2")
        console.print("[blue underline]Print 3")
        console.print("[blue underline]Print 4")

    capture_content = capture.get()
    print(repr(capture_content))
    assert capture_content == "Print 1\nPrint 2\nPrint 3\nPrint 4\n"

    recorded_content = console.export_text()
    print(repr(recorded_content))
    assert recorded_content == "Print 0\n"
Regression test for https://github.com/Textualize/rich/issues/2563
tests/test_console.py