This commit is contained in:
@@ -3,10 +3,11 @@ import types
|
||||
import sys
|
||||
import inspect as std_inspect
|
||||
|
||||
from IPython.core.oinspect import Inspector
|
||||
from IPython.core.oinspect import Inspector, OInfo
|
||||
from slic.utils.richcfg import replace_ipython_inspect # ← adapt this to your actual module path
|
||||
|
||||
|
||||
|
||||
# A realistic class to inspect
|
||||
class User:
|
||||
"""Represents a user in the system."""
|
||||
@@ -21,6 +22,11 @@ class User:
|
||||
"""Returns a welcome message."""
|
||||
return f"Welcome, {self.name}!"
|
||||
|
||||
def dict_to_oinfo(info_dict):
|
||||
info_obj = OInfo()
|
||||
for key, value in info_dict.items():
|
||||
setattr(info_obj, key, value)
|
||||
return info_obj
|
||||
|
||||
def test_rich_inspector_outputs_more_than_builtin(monkeypatch):
|
||||
# --- Simulate a fake IPython shell ---
|
||||
@@ -53,7 +59,10 @@ def test_rich_inspector_outputs_more_than_builtin(monkeypatch):
|
||||
original_stdout = sys.stdout
|
||||
sys.stdout = builtin_buf
|
||||
inspector = Inspector()
|
||||
info = inspector.info(user)
|
||||
|
||||
info_dict = inspector.info(user)
|
||||
info = dict_to_oinfo(info_dict)
|
||||
|
||||
inspector.pinfo(user, oname="user", info=info, detail_level=1)
|
||||
sys.stdout = original_stdout
|
||||
builtin_text = builtin_buf.getvalue()
|
||||
|
||||
Reference in New Issue
Block a user