I am testing a CLI application that operates on files. I am using pytest and pytest-datadir like this:
tests/test_entire_app.py
import subprocess
def test_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.
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.