| 1 |
from typing import ( |
| 2 |
TYPE_CHECKING, |
| 3 |
Any, |
| 4 |
) |
| 5 |
|
| 6 |
from syrupy.constants import TEXT_ENCODING |
| 7 |
|
| 8 |
from .single_file import SingleFileSnapshotExtension |
| 9 |
|
| 10 |
if TYPE_CHECKING: |
| 11 |
from syrupy.types import SerializableData |
| 12 |
|
| 13 |
|
| 14 |
class PNGImageSnapshotExtension(SingleFileSnapshotExtension): |
| 15 |
file_extension = "png" |
| 16 |
|
| 17 |
|
| 18 |
class SVGImageSnapshotExtension(SingleFileSnapshotExtension): |
| 19 |
file_extension = "svg" |
| 20 |
|
| 21 |
def serialize(self, data: "SerializableData", **kwargs: Any) -> bytes: |
| 22 |
return str(data).encode(TEXT_ENCODING) |