There is a class named State
that has several attributes, which I need to write unit tests for. The test will need to have certain actions that change attribute values of the State
instance. Expected parameters are located inside of the dictionary. The unit test will compare the attributes of the State
instance with the values of the dictionary for equality.
The question is what is the best place to keep the comparison logic at? I was thinking about 2 options:
- Add
__eq__
method to theState
class that contains comparison logic. - Add helper function inside of the test module that contains comparison logic.
Which one of the options is better and why?