MCPcopy Create free account
hub / github.com/plotly/plotly.py / test_sanitize_json

Function test_sanitize_json

tests/test_io/test_to_from_plotly_json.py:242–262  ·  view source on GitHub ↗
(engine)

Source from the content-addressed store, hash-verified

240
241
242def test_sanitize_json(engine):
243 layout = {"title": {"text": "</script>\u2028\u2029"}}
244 fig = go.Figure(layout=layout)
245 fig_json = pio.to_json_plotly(fig, engine=engine)
246 layout_2 = json.loads(fig_json)["layout"]
247 if "template" in layout_2:
248 del layout_2["template"]
249
250 assert layout == layout_2
251
252 replacements = {
253 "<": "\\u003c",
254 ">": "\\u003e",
255 "/": "\\u002f",
256 "\u2028": "\\u2028",
257 "\u2029": "\\u2029",
258 }
259
260 for bad, good in replacements.items():
261 assert bad not in fig_json
262 assert good in fig_json
263
264
265@pytest.mark.parametrize("na_value", [np.nan, pd.NaT, pd.NA])

Callers

nothing calls this directly

Calls 1

itemsMethod · 0.45

Tested by

no test coverage detected