Closed reagle closed 8 months ago
I'm not familiar with the pytest ecosystem. What you're describing sounds like "doctest". pytest-golden definitely doesn't look at docstrings and wouldn't be able to automatically update them. The thing it does is just update yaml files pretty much.
@oprypin, hi! Thanks for the response. I want to move away from doctests. I want to test the output of a program against a given "golden" output and was wondering if there was a way to do that with this plugin. However, it appears the files in this program have there own format (e.g., "input:") and are not actual program output?
Ah sure you could have input
be the command and output
be the program output. That works well.
But don't the input and output files expect input:
and output:
as their first lines respectively?
No you can use any field you like. You just need to reference it correctly.
E.g.
a: 1
b: 2
@pytest.mark.golden_test("*.yml")
def test_add(golden):
assert golden["a"] + 1 == golden.out["b"]
Just use golden
like a normal dictionary (loaded from the yaml) for the input and use golden.out
like a normal dictionary (parsed from the yaml) for the expected output. The reason to use golden.out
for the expected output is so that the yaml can be automatically updated.
Presently I have the following code, which is run as part of a doctest. I thought pytest and -golden might be able to do the same -- in a more standard manner. However, I'm a pytest newbie and not sure how and the input and output files aren't actual program input and output files. Can I test those with this module?