I have:
class MyClassA:
def __init__(...):
do some stuff
create object attributes
def myfunc:
get required data
create MyClassA object(s)
store MyClassA object(s) in a list
return(list of MyClassA object(s))
Now I'm writing unittests for myfunc like this:
import unittest
class Test_myfunc(unittest.TestCase):
sample_data = ...
expected_result = ??
self.assertEqual(myfunc(sample_data), expected_result)
What do I set expected_result to be? For the test to pass it should be a list of objects, but then it should have the same instances that are created when I pass the sample data into myfunc. If I create another instance of MyClassA in the unittest then it will obviously fail because the instances would be different. I would like to validate that for each object in the output list from myfunc the attributes match the sample_data. What is the right way to do this?
PS: I hope my question is clear.