generated from tophat/new-project-kit
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(serializer): handling of multi-part file extensions in SingleFile…
…Extension (#710) Co-authored-by: tolga.eren <tolga.eren@adevinta.com> Co-authored-by: noahnu <noahnu@gmail.com>
- Loading branch information
1 parent
b831ee2
commit efe687e
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from pathlib import Path | ||
|
||
|
||
def test_multiple_file_extensions(testdir): | ||
file_extension = "ext2.ext1" | ||
|
||
testcase = f""" | ||
import pytest | ||
from syrupy.extensions.single_file import SingleFileSnapshotExtension | ||
class DotInFileExtension(SingleFileSnapshotExtension): | ||
_file_extension = "{file_extension}" | ||
@pytest.fixture | ||
def snapshot(snapshot): | ||
return snapshot.use_extension(DotInFileExtension) | ||
def test_dot_in_filename(snapshot): | ||
assert b"expected_data" == snapshot | ||
""" | ||
|
||
test_file: Path = testdir.makepyfile(test_file=testcase) | ||
|
||
result = testdir.runpytest("-v", "--snapshot-update") | ||
result.stdout.re_match_lines((r"1 snapshot generated\.")) | ||
assert "snapshots unused" not in result.stdout.str() | ||
assert result.ret == 0 | ||
|
||
snapshot_file = ( | ||
Path(test_file).parent | ||
/ "__snapshots__" | ||
/ "test_file" | ||
/ f"test_dot_in_filename.{file_extension}" | ||
) | ||
assert snapshot_file.exists() | ||
|
||
result = testdir.runpytest("-v") | ||
result.stdout.re_match_lines((r"1 snapshot passed\.")) | ||
assert "snapshots unused" not in result.stdout.str() | ||
assert result.ret == 0 |