oprypin / pytest-golden

Plugin for pytest that offloads expected outputs to data files
MIT License
23 stars 2 forks source link

Add support for golden testing of whole files and directory trees #5

Open llucax opened 1 year ago

llucax commented 1 year ago

I have project that generates a bunch of files, so I was looking for a library to do golden testing but not for small outputs but whole files, or even whole trees.

For now I just implemented a hacky ad-hoc golden testing to check for whole directory trees and individual files, but it would be nice to use something more standard and less hacky.

This is actually the only Python golden testing library I found that looks legit, so I was wondering if there is any interest in supporting this use case. If so, I might even prepare and submit a PR eventually, but I will only dedicate this extra effort if the feature is welcome :)

Thanks!

oprypin commented 1 year ago

Hm interesting. At first I imagined that the overlap between the functionality of writing YAML files and writing directory trees is so little, but maybe it can be done in a good way. I don't know. Actually seems like a great idea now, just that I'm a picky reviewer :(

llucax commented 1 year ago

In case you are curious about the use case: https://github.com/frequenz-floss/frequenz-repo-config-python/blob/v0.x.x/tests/integration/test_cookiecutter_generation.py

(it's basically testing generation of templates using cookiecutter)

llucax commented 1 year ago

For more context, I used also golden testing in Flutter, to test whole rendering of visual objects. In that case what you normally do is export the rendering of an app as a PNG and then compare the generated PNGs to make sure you didn't screw your interface when introducing some changes. Using YAML to store blobs doesn't seem very practical either, so this could be another use case for this.

oprypin commented 10 months ago

Check out this other project https://twitter.com/15r10nk/status/1720350727178965154