Skip to content

Commit 3ccc4ed

Browse files
committed
Address review feedback
- use %r instead of %s to handle quoting more succintly - add a finally block to ensure browser state is transitioned from iframe back to default content
1 parent aa658d3 commit 3ccc4ed

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

notebook/tests/selenium/test_display_isolation.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77

88
def test_display_isolation(notebook):
9-
import_ln = """from IPython.core.display import HTML, SVG, display, display_svg"""
9+
import_ln = "from IPython.core.display import HTML, SVG, display, display_svg"
1010
notebook.edit_cell(index=0, content=import_ln)
1111
notebook.execute_cell(notebook.current_cell)
12-
isolated_html(notebook)
13-
isolated_svg(notebook)
12+
try:
13+
isolated_html(notebook)
14+
isolated_svg(notebook)
15+
finally:
16+
# Ensure we switch from iframe back to default content even if test fails
17+
notebook.browser.switch_to.default_content()
1418

1519

1620
def isolated_html(notebook):
@@ -22,18 +26,18 @@ def isolated_html(notebook):
2226
"""
2327
red = 'rgb(255, 0, 0)'
2428
blue = 'rgb(0, 0, 255)'
25-
test_str = """<div id='test'>Should be red from non-isolation</div>"""
26-
notebook.add_and_execute_cell(content="""display(HTML("%s"))""" % test_str)
29+
test_str = "<div id='test'>Should be red from non-isolation</div>"
30+
notebook.add_and_execute_cell(content="display(HTML(%r))" % test_str)
2731
non_isolated = (
2832
"<style>div{color:%s;}</style>" % red +
2933
"<div id='non-isolated'>Should be red</div>")
30-
display_ni = """display(HTML("%s"), metadata={"isolated":False})""" % (
34+
display_ni = "display(HTML(%r), metadata={'isolated':False})" % (
3135
non_isolated)
3236
notebook.add_and_execute_cell(content=display_ni)
3337
isolated = (
3438
"<style>div{color:%s;}</style>" % blue +
3539
"<div id='isolated'>Should be blue</div>")
36-
display_i = """display(HTML("%s"), metadata={"isolated":True})""" % (
40+
display_i = "display(HTML(%r), metadata={'isolated':True})" % (
3741
isolated)
3842
notebook.add_and_execute_cell(content=display_i)
3943

0 commit comments

Comments
 (0)