You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am testing a CLI application that operates on files. I am using pytest and pytest-datadir like this:
tests/test_entire_app.py
importsubprocessdeftest_scenario_one(datadir, snapshot):
d=datadir/"test_scenario_one"p=subprocess.run(["myapp", d], capture_output=True, text=True)
assert<somehow_load_directory_to_compare(d)>==snapshot# somehow snapshot should save that directory
What I'm doing right now is manually with open(f): data1 = f.read() for each expected output test file. Then all those go in a dict object { "app.ts": appts, "app.js": appjs, ... } which gets mashed into a huge .ambr file. I'd prefer a regular real directory structure if possible.
...but I'm not familiar with how to go about actually doing that. I would appreciate some guidance about how to do this. I see that there's some examples of how to use the syrupy.extensions.single_file which seems cool, but I don't know how to go about making an extension that creates a directory with multiple files.
The text was updated successfully, but these errors were encountered:
The "detect unused snapshot" files logic assumes a snapshot lives in one file I believe, but everything else should be possible at least with a custom extension.
I can take a look in a couple days and see if I can put together an example for you.
What's your question?
I am testing a CLI application that operates on files. I am using pytest and pytest-datadir like this:
tests/test_entire_app.py
What I'm doing right now is manually
with open(f): data1 = f.read()
for each expected output test file. Then all those go in a dict object{ "app.ts": appts, "app.js": appjs, ... }
which gets mashed into a huge.ambr
file. I'd prefer a regular real directory structure if possible.I want it to result in something like this:
...but I'm not familiar with how to go about actually doing that. I would appreciate some guidance about how to do this. I see that there's some examples of how to use the syrupy.extensions.single_file which seems cool, but I don't know how to go about making an extension that creates a directory with multiple files.
The text was updated successfully, but these errors were encountered: