I have a class that represents a certain complex state. That state can change, and I I have another instance of that class that represents the "true" state. I wrote a function that does some diffing logic and figures out how to get the current state to the true state, if they differ.
I'd like to test that function using pytest. There are many scenarios possibilities, but the test logic is pretty simple and boils down to (pseudo python code):
def test_diffing(current_state, prescribed_state):
properties_to_add = []
properties_to_delete = []
properties_to_modify = []
properties_to_add, properties_to_delete, properties_to_modify = diff_logic(current_state, prescribed_state)
assert properties_to_add == 1
assert properties_to_delete == 0
assert properties_to_modify == 3
The numbers on the right hand side of the assert depend on what the current_state is. I have many current_state scenarios.
What is the best way to write a single unit test as above, with many pairs of fixtures such that the current_state is passed along with the expected values of the asserts?
I have looked at pytest fixtures parametrization but the problem with this approach is that it's using decorators and that gets ugly* very quickly, especially with a large number of arguments and large number of test cases. It seems that this is not what I should be using fixtures for.
What's the best way to achieve what I'm trying to do cleanly?
*I am saying it gets ugly because having 15 or 20 sets of arguments to a decorator is very confusing and puts a lot of logic in the decorator itself.