From c7f3a97f4c1f71284f7342648ec4b1b5797b57fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Mon, 27 May 2024 11:24:00 +0200 Subject: [PATCH] Fix hv.help if no store --- holoviews/core/options.py | 2 +- holoviews/tests/util/test_help.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/holoviews/core/options.py b/holoviews/core/options.py index 1bb4a7a127..35f7b4e79a 100644 --- a/holoviews/core/options.py +++ b/holoviews/core/options.py @@ -1253,7 +1253,7 @@ def info(cls, obj, ansi=True, backend='matplotlib', visualization=True, parameterized_class = (isinstance(obj,type) and issubclass(obj,param.Parameterized)) info = None - if parameterized_object or parameterized_class: + if InfoPrinter.store and (parameterized_object or parameterized_class): info = InfoPrinter.info(obj, ansi=ansi, backend=backend, visualization=visualization, pattern=pattern, elements=elements) diff --git a/holoviews/tests/util/test_help.py b/holoviews/tests/util/test_help.py index 9b19751686..4b7945b8a2 100644 --- a/holoviews/tests/util/test_help.py +++ b/holoviews/tests/util/test_help.py @@ -9,3 +9,15 @@ def test_help_pattern(capsys): hv.help(hv.Curve, pattern='border') captured = capsys.readouterr() assert '\x1b[43;1;30mborder\x1b[0m' in captured.out + + +@pytest.mark.usefixtures("bokeh_backend") +def test_help_pattern_no_ipython(capsys): + info_store = hv.core.pprint.InfoPrinter.store + try: + hv.core.pprint.InfoPrinter.store = None + hv.help(hv.Curve) + captured = capsys.readouterr() + assert captured.out.startswith('Help on class Curve') + finally: + hv.core.pprint.InfoPrinter.store = info_store