MCPcopy Index your code
hub / github.com/plotly/plotly.py / test_bytesio

Function test_bytesio

tests/test_optional/test_kaleido/test_kaleido.py:162–173  ·  view source on GitHub ↗

Verify that writing to a BytesIO object contains the same data as to_image(). The goal of this test is to ensure that Plotly correctly handles a writable buffer which doesn't correspond to a filesystem path.

()

Source from the content-addressed store, hash-verified

160
161
162def test_bytesio():
163 """Verify that writing to a BytesIO object contains the same data as to_image().
164
165 The goal of this test is to ensure that Plotly correctly handles a writable buffer
166 which doesn't correspond to a filesystem path.
167 """
168 bio = BytesIO()
169 pio.write_image(fig, bio, format="jpg", engine="kaleido", validate=False)
170 bio.seek(0) # Rewind to the beginning of the buffer, otherwise read() returns b''.
171 bio_bytes = bio.read()
172 to_image_bytes = pio.to_image(fig, format="jpg", engine="kaleido", validate=False)
173 assert bio_bytes == to_image_bytes
174
175
176def test_defaults():

Callers

nothing calls this directly

Calls 4

write_imageMethod · 0.80
readMethod · 0.80
to_imageMethod · 0.80
seekMethod · 0.45

Tested by

no test coverage detected