File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ """Shared pytest fixtures for snapshot testing."""
2+
3+ from __future__ import annotations
4+
5+ import pytest
6+ from syrupy .assertion import SnapshotAssertion
7+ from syrupy .extensions .json import JSONSnapshotExtension
8+ from syrupy .extensions .single_file import SingleFileSnapshotExtension , WriteMode
9+
10+
11+ class YamlSnapshotExtension (SingleFileSnapshotExtension ):
12+ """Snapshot extension that persists plain-text YAML files."""
13+
14+ file_extension = "yaml"
15+ _write_mode = WriteMode .TEXT
16+
17+
18+ @pytest .fixture
19+ def snapshot_json (snapshot : SnapshotAssertion ) -> SnapshotAssertion :
20+ """JSON-formatted snapshot assertions."""
21+ return snapshot .with_defaults (extension_class = JSONSnapshotExtension )
22+
23+
24+ @pytest .fixture
25+ def snapshot_yaml (snapshot : SnapshotAssertion ) -> SnapshotAssertion :
26+ """YAML-formatted snapshot assertions."""
27+ return snapshot .with_defaults (extension_class = YamlSnapshotExtension )
You can’t perform that action at this time.
0 commit comments