| 123456789101112131415161718192021222324252627 |
- from io import BytesIO
- import pytest
- def get_mpl_fig():
- pytest.importorskip("matplotlib")
- import matplotlib.pyplot as plt
- # Data for plotting
- fig, ax = plt.subplots()
- ax.plot([1, 2, 3])
- buf = BytesIO()
- fig.savefig(buf, format='png')
- buf.seek(0)
- bytes = buf.read()
- return fig, bytes
- def get_pil_image():
- pytest.importorskip("PIL")
- from PIL import Image
- img = Image.new('RGB', (100, 30), color = (73, 109, 137))
- buf = BytesIO()
- img.save(buf, format='PNG')
- buf.seek(0)
- bytes = buf.read()
- return img, bytes
|