File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import plotly .io as pio
1414from plotly .offline import get_plotlyjs
1515from plotly .io ._utils import plotly_cdn_url
16+ from plotly .io ._html import _generate_sri_hash
1617
1718if sys .version_info >= (3 , 3 ):
1819 import unittest .mock as mock
@@ -298,12 +299,19 @@ def test_repr_html(renderer):
298299 # id number of figure
299300 id_html = str_html .split ('document.getElementById("' )[1 ].split ('")' )[0 ]
300301 id_pattern = "cd462b94-79ce-42a2-887f-2650a761a144"
302+
303+ # Calculate the SRI hash dynamically
304+ plotlyjs_content = get_plotlyjs ()
305+ sri_hash = _generate_sri_hash (plotlyjs_content )
306+
301307 template = (
302308 '<div> <script type="text/javascript">'
303309 "window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n "
304310 '<script charset="utf-8" src="'
305311 + plotly_cdn_url ()
306- + '" integrity="sha256-oy6Be7Eh6eiQFs5M7oXuPxxm9qbJXEtTpfSI93dW16Q=" crossorigin="anonymous"></script> '
312+ + '" integrity="'
313+ + sri_hash
314+ + '" crossorigin="anonymous"></script> '
307315 '<div id="cd462b94-79ce-42a2-887f-2650a761a144" class="plotly-graph-div" '
308316 'style="height:100%; width:100%;"></div> <script type="text/javascript">'
309317 " window.PLOTLYENV=window.PLOTLYENV || {};"
You can’t perform that action at this time.
0 commit comments