MCPcopy Index your code
hub / github.com/plotly/plotly.py / test_repr_html

Function test_repr_html

tests/test_io/test_renderers.py:295–331  ·  view source on GitHub ↗
(renderer)

Source from the content-addressed store, hash-verified

293 + ["notebook", "notebook_connected", "browser", "notebook+plotly_mimetype"],
294)
295def test_repr_html(renderer):
296 pio.renderers.default = renderer
297 fig = go.Figure()
298 fig.update_layout(template=None)
299 str_html = fig._repr_html_()
300 bundle = fig._repr_mimebundle_()
301 # id number of figure
302 id_html = str_html.split('document.getElementById("')[1].split('")')[0]
303 id_pattern = "cd462b94-79ce-42a2-887f-2650a761a144"
304
305 # Calculate the SRI hash dynamically
306 plotlyjs_content = get_plotlyjs()
307 sri_hash = _generate_sri_hash(plotlyjs_content)
308
309 template = (
310 '<div style="height:100%; width:100%;"> <script>'
311 "window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n "
312 '<script charset="utf-8" src="'
313 + plotly_cdn_url()
314 + '" integrity="'
315 + sri_hash
316 + '" crossorigin="anonymous"></script> '
317 '<div id="cd462b94-79ce-42a2-887f-2650a761a144" class="plotly-graph-div" '
318 'style="height:100%; width:100%;"></div> <script>'
319 " window.PLOTLYENV=window.PLOTLYENV || {};"
320 ' if (document.getElementById("cd462b94-79ce-42a2-887f-2650a761a144"))'
321 ' { Plotly.newPlot( "cd462b94-79ce-42a2-887f-2650a761a144",'
322 ' [], {"template":{}},'
323 ' {"responsive": true} ) };'
324 " </script> </div>"
325 )
326 if "text/html" in bundle:
327 str_bundle = bundle["text/html"]
328 id_bundle = str_bundle.split('document.getElementById("')[1].split('")')[0]
329 assert str_html.replace(id_html, "") == str_bundle.replace(id_bundle, "")
330 else:
331 assert str_html.replace(id_html, "") == template.replace(id_pattern, "")
332
333
334all_renderers_without_orca = [

Callers

nothing calls this directly

Calls 8

update_layoutMethod · 0.95
get_plotlyjsFunction · 0.90
_generate_sri_hashFunction · 0.90
plotly_cdn_urlFunction · 0.90
_repr_html_Method · 0.45
_repr_mimebundle_Method · 0.45
splitMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected