This is an example of a simple pytest fixture that loads reference test data from alongside the test code itself. Any test that uses the
refdata fixture has to have a file called
test_abc is the name of the test module (e.g.
xyz is the name of the test function without the
test_ prefix. We can discuss how we best want to organise this - we might for example want one test per file and just require a
test_abc.txt file to exist alongside
test_abc.py, or we might want to allow multiple tests on the same data by loading the data into a dict of some sort. It should also be possible to load data from the variables defined in the test module itself.
This provides a simple way for non-developers to contribute tests to Finesse - they simply have to provide a text file with their data, and a test function to perform the Finesse 3 run to compare against.
Originally I looked at
pytest-datafiles as plugins but these don't load the data automatically so the user would still have to include a
np.genfromtxt() or similar call in every test. My approach here is to load the data and provide it to the test as a numpy array automatically.
@jonathan.perry, do you want to take a look at this and see if you're happy? Maybe we should discuss how best to organise the tests and data, as outlined above, and make changes as appropriate to the
conftest.py file in this MR.