File: test_custom_snapshot_directory.py

package info (click to toggle)
python-syrupy 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,396 kB
  • sloc: python: 5,982; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 754 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
"""
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