Skip to content

Commit 3185ed3

Browse files
committed
Calculate hash in tests dynamically to avoid future breakage
1 parent 3aa6d25 commit 3185ed3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/test_io/test_renderers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import plotly.io as pio
1414
from plotly.offline import get_plotlyjs
1515
from plotly.io._utils import plotly_cdn_url
16+
from plotly.io._html import _generate_sri_hash
1617

1718
if 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 || {};"

0 commit comments

Comments
 (0)