File: test_image_png.py

package info (click to toggle)
python-syrupy 4.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,368 kB
  • sloc: python: 5,978; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import base64

import pytest

from syrupy.extensions.image import PNGImageSnapshotExtension

actual_png = base64.b64decode(
    b"iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAMAAADsEZWCAAAAG1BMVEXMzMy"
    b"Wlpaqqqq3t7exsbGcnJy+vr6jo6PFxcUFpPI/AAAACXBIWXMAAA7EAAAOxA"
    b"GVKw4bAAAAQUlEQVQ4jWNgGAWjgP6ASdncAEaiAhaGiACmFhCJLsMaIiDAE"
    b"QEi0WXYEiMCOCJAJIY9KuYGTC0gknpuHwXDGwAA5fsIZw0iYWYAAAAASUVO"
    b"RK5CYII="
)


@pytest.fixture
def snapshot_png(snapshot):
    return snapshot.use_extension(PNGImageSnapshotExtension)


def test_image(snapshot_png):
    assert actual_png == snapshot_png


def test_multiple_snapshot_extensions(snapshot):
    """
    Example of switching extension classes on the fly.
    These should be indexed in order of assertion.
    """
    assert actual_png == snapshot(extension_class=PNGImageSnapshotExtension)
    assert actual_png == snapshot()  # uses initial extension class
    assert snapshot._extension is not None
    assert actual_png == snapshot(extension_class=PNGImageSnapshotExtension)