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

Function test_fig_write_image

tests/test_optional/test_kaleido/test_kaleido.py:279–296  ·  view source on GitHub ↗

Test that fig.write_image() calls the correct underlying Kaleido function.

()

Source from the content-addressed store, hash-verified

277
278
279def test_fig_write_image():
280 """Test that fig.write_image() calls the correct underlying Kaleido function."""
281
282 test_fig = go.Figure(fig)
283 test_image_bytes = b"mock image data"
284
285 if kaleido_major() > 0:
286 patch_funcname = "plotly.io._kaleido.kaleido.calc_fig_sync"
287 else:
288 patch_funcname = "plotly.io._kaleido.scope.transform"
289
290 with patch(patch_funcname, return_value=test_image_bytes) as mock_calc_fig:
291 test_fig.write_image("test_path.png")
292
293 # Verify patched function was called once with fig dict as first argument
294 mock_calc_fig.assert_called_once()
295 args, _ = mock_calc_fig.call_args
296 assert args[0] == test_fig.to_dict()
297
298
299def test_fig_to_image():

Callers

nothing calls this directly

Calls 3

kaleido_majorFunction · 0.90
write_imageMethod · 0.80
to_dictMethod · 0.80

Tested by

no test coverage detected