Skip to content

Commit

Permalink
fix: allow snapshot dir to be different (#892)
Browse files Browse the repository at this point in the history
* fix: allow snapshot dir to be different

* chore: format code
  • Loading branch information
joostlek authored Oct 6, 2024
1 parent e79cd04 commit 548ec06
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/syrupy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def in_snapshot_dir(path: Path) -> bool:

def walk_snapshot_dir(root: str) -> Iterator[str]:
for filepath in Path(root).rglob("*"):
if not in_snapshot_dir(filepath):
continue
if not filepath.name.startswith(".") and filepath.is_file():
yield str(filepath)

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_snapshot_outside_directory.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest


@pytest.fixture
def testcases(testdir, tmp_path):
dirname = tmp_path.joinpath("__snapshots__")
@pytest.fixture(params=["__snapshots__", "snapshots"])
def testcases(testdir, tmp_path, request):
dirname = tmp_path.joinpath(request.param)
testdir.makeconftest(
f"""
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/syrupy/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def test_walk_dir_skips_non_snapshot_path(testfiles):
_, testdir = testfiles
snap_folder = Path("__snapshots__")
assert {
str(Path(p).relative_to(Path.cwd())) for p in walk_snapshot_dir(testdir.tmpdir)
str(Path(p).relative_to(Path.cwd()))
for p in walk_snapshot_dir(Path(testdir.tmpdir).joinpath(snap_folder))
} == {
str(snap_folder.joinpath("snapfile1.ambr")),
str(snap_folder.joinpath("snapfolder", "snapfile2.svg")),
Expand Down

0 comments on commit 548ec06

Please sign in to comment.