1

I have an assertion like this -

obj_instance_1 = SomeType(a=1,b=2,c=3)
//invoke the test function
mock_calls = [
            mock.call(param1=obj_instance_1, param2=mocked_obj),
            mock.call(param1=obj_instance_1, param2=mocked_obj),
        ]
mock_instance.assert_has_calls(mock_calls)

assert_has_calls assertion fails with the error-

Expected: [call(param2=<MagicMock name='SomeName' id='140133686336928'>, param1=<SomeType(a=1,b=2,c=3)>),
call(param2=<MagicMock name='SomeName' id='140133686336928'>, param1=<SomeType(a=1,b=2,c=3)>)]
Actual: 
[call(param2=<MagicMock name='SomeName' id='140133686336928'>, param1=<SomeType(b=2,a=1,c=3)>),
call(param2=<MagicMock name='SomeName' id='140133686336928'>, param1=<SomeType(b=2,a=1,c=3)>)]

The only difference I see is the order of attributes of param1 object are different in Expected and Actual. But the values of attributes of the object are same. Why would it be causing the test to fail?

krackoder
  • 2,841
  • 7
  • 42
  • 51

0 Answers0