ฉันพยายามจะใช้ assert_called_once_with จาก unittest.ล้อเลียน https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.assert_called_once_with
แต่ฉันอยากจะตรวจสอบว่า 2 โหของวัตถุต้องผ่านกับเอ็ถูกต้องแอททริบิวต์ต่างๆ.
ดังนั้นอยู่ในห้องฉัน overrided ง __eq__
func:
def __eq__(self, other):
return (
self.id == other.id
and self.users == other.users
)
และในครหัสฉันเคยเหมือนนี้
mock_add_user.assert_called_once_with(context_fix, expected_user_obj1, expected_user_obj2, users)
แต่ผมก็ยังโดนข้อผิดพลาดเกิดขึ้นระหว่างและ teste เอาเปรียบเทียบที่ repr ของตัวอย่างเช่นเช่นนี้
<app.domain.model.load_md.Load object at 0x10cb7d7d0>
E AssertionError: Expected call: add_user(<app.infrastructure.context.Context object at 0x10cb7da50>, <app.domain.model.load_md.Load object at 0x10cb7d7d0>, <app.domain.model.load_md.Load object at 0x10cb7d550>, [1, 2, 3, 2])
E Actual call: add_user(<app.infrastructure.context.Context object at 0x10cb7da50>, <app.domain.model.load_md.Load object at 0x10ca7f5d0>, <app.domain.model.load_md.Load object at 0x10cd1e650>, [1, 2, 3, 2])
ฉันต้องการจริงๆทางที่จะพิสูจน์ว่าเป็นตัวอย่างของสิ่งมีการผ่านที่เป็นพารามิเตอร์ของฟังก์ชันกับที่ถูกต้องคุณลักษณะเติมเต็ม.