diff --git a/IPython/core/tests/test_oinspect.py b/IPython/core/tests/test_oinspect.py index 2fe28f5..4cb9268 100644 --- a/IPython/core/tests/test_oinspect.py +++ b/IPython/core/tests/test_oinspect.py @@ -492,7 +492,7 @@ def test_pinfo_docstring_if_detail_and_no_source(): sys.version_info.releaselevel not in ("final", "candidate"), reason="fails on 3.13.dev", ) -def test_pinfo_docstring_dynamic(): +def test_pinfo_docstring_dynamic(capsys): obj_def = """class Bar: __custom_documentations__ = { "prop" : "cdoc for prop", @@ -513,20 +513,25 @@ def test_pinfo_docstring_dynamic(): ip.run_cell("b = Bar()") - with AssertPrints("Docstring: cdoc for prop"): - ip.run_line_magic("pinfo", "b.prop") + ip.run_line_magic("pinfo", "b.prop") + captured = capsys.readouterr() + assert "Docstring: cdoc for prop" in captured.out - with AssertPrints("Docstring: cdoc for non_exist"): - ip.run_line_magic("pinfo", "b.non_exist") + ip.run_line_magic("pinfo", "b.non_exist") + captured = capsys.readouterr() + assert "Docstring: cdoc for non_exist" in captured.out - with AssertPrints("Docstring: cdoc for prop"): - ip.run_cell("b.prop?") + ip.run_cell("b.prop?") + captured = capsys.readouterr() + assert "Docstring: cdoc for prop" in captured.out - with AssertPrints("Docstring: cdoc for non_exist"): - ip.run_cell("b.non_exist?") + ip.run_cell("b.non_exist?") + captured = capsys.readouterr() + assert "Docstring: cdoc for non_exist" in captured.out - with AssertPrints("Docstring: "): - ip.run_cell("b.undefined?") + ip.run_cell("b.undefined?") + captured = capsys.readouterr() + assert "Docstring: " in captured.out def test_pinfo_magic():