Test that fig.write_image() calls the correct underlying Kaleido function.
()
| 277 | |
| 278 | |
| 279 | def 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 | |
| 299 | def test_fig_to_image(): |
nothing calls this directly
no test coverage detected