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 the State 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?
Outside. __eq__ should (in most cases) not be used to compare a specific object to a dict and give equality. The expected behaviour is to enable comparison between objects of the same (or inherited) type. If you're looking for a way to compare to State objects, it could be useful - but that doesn't seem to be the case here, according to your description.
I'd also be careful about using __eq__ for specific tests if these tests do not explicitly test for equality, but for certain properties. A future change in __eq__ - i.e. the comparison requirement between objects of the same class, may not be have the same semantic meaning as what you're actually testing in your test. For example; a future change to __eq__ could introduce more similarity requirements than what your tests require (for example; are they actually the same object and not just similar). Since the expected behaviour for __eq__ is "this represents exactly the same thing", that may not be the same as what you're testing.
Keep the comparison outside of your class - and if it's something you want to re-use in different contexts, either add it as a utility function in your project or add it as a specific function to your object. For now I'd just go with keeping it in your tests, and then moving it inside your project when it becomes necessary.
This all assumes that the comparison is simple. If there is actual logic and calculations involved - that does not belong in the test. Instead, add logic to your class that exposes the values directly in a properly testable format.
A test should just check that the value returned matches what was expected. However, comparing a returned dict against expected values for that dict is perfectly valid.
What is the correct way to test classes in Python?