joseph-roitman / pytest-snapshot

A plugin for snapshot testing with pytest.
MIT License
114 stars 12 forks source link

Support nested dictionaries in assert_match_dir #47

Closed joseph-roitman closed 2 years ago

joseph-roitman commented 2 years ago

snapshot.assert_match_dir should support snapshotting nested dictionaries as a nested directory structure.

For example

snapshot.assert_match_dir({
    'file1.txt': 'file1_contents',
    'sub_directory': {
        'file2.txt': 'file2_contents',
    }
}, 'snapshot-name')

will create a directory named snapshot-name containing file1.txt and sub_directory. sub_directory will contain file2.txt.

Discussed in https://github.com/joseph-roitman/pytest-snapshot/discussions/46

Originally posted by **alfechner** November 25, 2021 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