(renderer)
| 293 | + ["notebook", "notebook_connected", "browser", "notebook+plotly_mimetype"], |
| 294 | ) |
| 295 | def 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 | |
| 334 | all_renderers_without_orca = [ |
nothing calls this directly
no test coverage detected