tophat / syrupy

:pancakes: The sweeter pytest snapshot plugin
https://tophat.github.io/syrupy
Apache License 2.0
485 stars 33 forks source link

Write single file snapshots immediately, even with `python-xdist` #841

Open rassie opened 7 months ago

rassie commented 7 months ago

Is your feature request related to a problem? Please describe.

In https://github.com/tophat/syrupy/issues/535 and adjacent issues, a compatibility layer with python-xdist has been implemented (thanks by the way!). One problem remains though: the snapshots are now collected in memory to be written at once at the end of the session. This is sensible for Amber files with multiple results, however, with large snapshots (e.g. images/screenshots), the memory footprint rises fast -- and there is probably no need to delay snapshot writing for anything derived from SingleFileSnapshotExtension, since there is only once process/thread writing to that single file.

Describe the solution you'd like

Restrict in-memory snapshot collection to certain extensions, e.g. by providing a flag and setting this flag appropriately on built-in extensions.