From 702c988300401de057e9ed5f43ce49ffcef0d386 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Mon, 30 May 2022 13:09:44 +0200 Subject: [PATCH 1/3] Add richInspectVariables test with HTML repr --- ipykernel/tests/test_debugger.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ipykernel/tests/test_debugger.py b/ipykernel/tests/test_debugger.py index 6b9c817cd..82e11b659 100644 --- a/ipykernel/tests/test_debugger.py +++ b/ipykernel/tests/test_debugger.py @@ -220,11 +220,13 @@ def test_rich_inspect_not_at_breakpoint(kernel_with_debug): def test_rich_inspect_at_breakpoint(kernel_with_debug): - code = """def f(a, b): + code = """def f(a, b, html): c = a + b return c -f(2, 3)""" +from IPython.core.display import HTML +html = HTML("

Hello World!

") +f(2, 3, html)""" r = wait_for_debug_request(kernel_with_debug, "dumpCell", {"code": code}) source = r["body"]["sourcePath"] @@ -276,6 +278,14 @@ def test_rich_inspect_at_breakpoint(kernel_with_debug): assert reply["body"]["data"] == {"text/plain": locals_[0]["value"]} + reply = wait_for_debug_request( + kernel_with_debug, + "richInspectVariables", + {"variableName": locals_[2]["name"], "frameId": stacks[0]["id"]}, + ) + + assert reply["body"]["data"] == {'text/html': '

Hello World!

', 'text/plain': ''} + def test_convert_to_long_pathname(): if sys.platform == "win32": From 46167a19fce751abfd9f65ae4106a17e3b4490a8 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Mon, 30 May 2022 14:03:53 +0200 Subject: [PATCH 2/3] Update expected result --- ipykernel/tests/test_debugger.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ipykernel/tests/test_debugger.py b/ipykernel/tests/test_debugger.py index 82e11b659..ebc04a148 100644 --- a/ipykernel/tests/test_debugger.py +++ b/ipykernel/tests/test_debugger.py @@ -1,5 +1,6 @@ import sys +from IPython.core.display import HTML import pytest from .utils import TIMEOUT, get_reply, new_kernel @@ -220,12 +221,15 @@ def test_rich_inspect_not_at_breakpoint(kernel_with_debug): def test_rich_inspect_at_breakpoint(kernel_with_debug): - code = """def f(a, b, html): + text_html = "

Hello World!

" + text_plain = str(HTML(text_html)) + + code = f"""def f(a, b, html): c = a + b return c from IPython.core.display import HTML -html = HTML("

Hello World!

") +html = HTML("{text_html}") f(2, 3, html)""" r = wait_for_debug_request(kernel_with_debug, "dumpCell", {"code": code}) @@ -284,7 +288,10 @@ def test_rich_inspect_at_breakpoint(kernel_with_debug): {"variableName": locals_[2]["name"], "frameId": stacks[0]["id"]}, ) - assert reply["body"]["data"] == {'text/html': '

Hello World!

', 'text/plain': ''} + assert reply["body"]["data"] == { + "text/html": text_html, + "text/plain": text_plain, + } def test_convert_to_long_pathname(): From a606057194534deb16ebeefb57daab9c93bb90dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 14:47:53 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ipykernel/tests/test_debugger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipykernel/tests/test_debugger.py b/ipykernel/tests/test_debugger.py index ebc04a148..f6b6464f2 100644 --- a/ipykernel/tests/test_debugger.py +++ b/ipykernel/tests/test_debugger.py @@ -1,7 +1,7 @@ import sys -from IPython.core.display import HTML import pytest +from IPython.core.display import HTML from .utils import TIMEOUT, get_reply, new_kernel