Replies: 4 comments 9 replies
-
|
Hi, Here are some requirements I thought of:
Other thoughts:
Here are some possible APIs I thought of (feel free to suggest better names): Extend assert_match_dirWe could extend from pytest_snapshot import load_filesystem_as_dict
d = load_filesystem_as_dict('path/to/generated/directory/or/file')
snapshot.assert_match_dir(d, 'my-snapshot-name')This is nice because it makes Adding support for registering custom snapshot typesOther people have asked for similar functionality. We could support from pathlib import Path
snapshot.register_type_snapshot(Path, load_filesystem_as_dict)
snapshot.assert_match(Path('path/to/generated/directory/or/file'), 'my-snapshot-name')I wouldn't want to call from pytest_snapshot import Filesystem
snapshot.assert_match(Filesystem('path/to/generated/directory/or/file'), 'my-snapshot-name')It is a bit annoying that you need to import pytest_snapshot and its not obvious what is happening without reading the docs. New functionThe benefit here is that it is pretty straightforward what is happening, but the downside is that we are adding another method. Are we going to start adding more and more methods as time goes on? snapshot.assert_match_filesystem('path/to/generated/directory/or/file', 'my-snapshot-name')What do you think? I am leaning towards extending |
Beta Was this translation helpful? Give feedback.
-
|
I see. I din't think of the implication of path's as string on i.e. Windows users. Very good point. Also I didn't consider this nested dict structure. I like it. Creating the dict via i.e. What is the current behaviour if a user passes a dict as a value? Is it stored in the file? If yes the nested dict structure you proposed is a change in behaviour. I don't think I'll find time before next week, so I'd be happy if you want to start on it. If not I can jump in next week or the week after. |
Beta Was this translation helpful? Give feedback.
-
That's a good question. The current behavior is to raise an exception (only str and bytes are supported) so it isn't a breaking change. The library might in the future add support for snapshotting other types (as we discussed previously). So the solutions are:
I think (1) is ideal. |
Beta Was this translation helpful? Give feedback.
-
|
I implemented the nested dictionaries in v0.8.0. Update me if you have any problems. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
we've got a tool which generates a bunch of files in a nested directory structure. We test the tool by snapshotting the entire directory and save it in exactly the same structure for comparison. Would you be interested in a PR to incorporate this peace of functionality?
Cheers,
Alex
Beta Was this translation helpful? Give feedback.
All reactions