Skip if PIL can't write JPEGs to BytesIO objects
()
| 43 | |
| 44 | |
| 45 | def _check_pil_jpeg_bytes(): |
| 46 | """Skip if PIL can't write JPEGs to BytesIO objects""" |
| 47 | # PIL's JPEG plugin can't write to BytesIO objects |
| 48 | # Pillow fixes this |
| 49 | from PIL import Image |
| 50 | |
| 51 | buf = BytesIO() |
| 52 | img = Image.new("RGB", (4, 4)) |
| 53 | try: |
| 54 | img.save(buf, "jpeg") |
| 55 | except Exception as e: |
| 56 | ename = e.__class__.__name__ |
| 57 | raise pytest.skip("PIL can't write JPEG to BytesIO: %s: %s" % (ename, e)) from e |
| 58 | |
| 59 | |
| 60 | @dec.skip_without("PIL.Image") |
no test coverage detected
searching dependent graphs…