code: def test_cast_recursive():
      class B:
          def __rich__(self) -> "A":
              return A()
  
          def __repr__(self) -> str:
              return "<B>"
  
      class A:
          def __rich__(self) -> B:
              return B()
  
          def __repr__(self) -> str:
              return "<A>"
  
      console = Console(file=io.StringIO())
      console.print(A())
      assert console.file.getvalue() == "<B>\n"
  
file_path: rich/tests/test_protocol.py
imports: import io
  from rich.abc import RichRenderable
  from rich.console import Console
  from rich.panel import Panel
  from rich.text import Text
label_desc: Use image node_id 6 for calling a global function with example usage: test_cast_recursive() and returns: A, str, B, str