Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

test: normalize plotly wrapper div style in snapshots (#9858)

Myles Scolnick6150ce7b9f89
diff --git a/tests/mocks.py b/tests/mocks.py
index 1871b3c4ad..3052c42b99 100644
--- a/tests/mocks.py
+++ b/tests/mocks.py
@@ -229,6 +229,15 @@ def simplify_plotly(output: str) -> str:
output = output.replace('<script type="text/javascript">', "<script>")
output = output.replace('<script type=\\"text/javascript\\">', "<script>")
+ # Normalize the outer wrapper <div> that precedes the PlotlyConfig script.
+ # (Plotly versions differ on whether it carries a style attribute, e.g.
+ # `<div style="height:100%; width:100%;">`)
+ output = re.sub(
+ r"<div\b[^>]*>(\s*<script>window\.PlotlyConfig)",
+ r"<div>\1",
+ output,
+ )
+
# Sanitize raw Plotly HTML output (from mo.ui.plotly())
# Replace random UUID-like div IDs (handles both escaped and unescaped quotes)
output = re.sub(