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
|
"""
Example: Custom Snapshot Directory
Here we extend the Amber extension to change the directory
in which snapshots are stored.
We explicitly name our new fixture "snapshot" to override the
default snapshot fixture. If this is placed in your project's
root conftest.py file, it is equivalent to globally overriding
the default snapshot directory.
"""
import pytest
from syrupy.extensions.amber import AmberSnapshotExtension
DIFFERENT_DIRECTORY = "__snaps_example__"
class DifferentDirectoryExtension(AmberSnapshotExtension):
snapshot_dirname = DIFFERENT_DIRECTORY
@pytest.fixture
def snapshot(snapshot):
return snapshot.use_extension(DifferentDirectoryExtension)
def test_case_1(snapshot):
assert "Syrupy is amazing!" == snapshot
|