Skip to content

Commit

Permalink
Fix variables service error handling (#4793)
Browse files Browse the repository at this point in the history
Addresses #4777. See the issue for QA notes.
  • Loading branch information
seeM authored Sep 25, 2024
1 parent d3f087d commit f7dad9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,30 @@ def test_list_1000(shell: PositronShell, variables_comm: DummyComm) -> None:
assert variables[999].get("display_name") == "var999"


def test_list_falls_back_on_variable_error(
shell: PositronShell, variables_comm: DummyComm, monkeypatch
) -> None:
"""
Should fall back to a basic variable summary if the inspector encounters an error (#4777).
"""
shell.user_ns["x"] = 1

# Temporarily break the NumberInspector.
def NumberInspector(*args, **kwargs):
raise Exception()

from positron_ipykernel.inspectors import INSPECTOR_CLASSES

monkeypatch.setitem(INSPECTOR_CLASSES, "number", NumberInspector)

# Request the list of variables.
list_result = _do_list(variables_comm)

# Spot check the listed fallback variable.
assert list_result["length"] == len(list_result["variables"]) == 1
assert list_result["variables"][0].display_name == "x"


def test_update_max_children_plus_one(
shell: PositronShell, variables_comm: DummyComm, monkeypatch
) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ def _summarize_variable(
has_children=False,
has_viewer=False,
is_truncated=False,
updated_time=timestamp(),
)


Expand Down

0 comments on commit f7dad9d

Please sign in to comment.