chained

Python – Mocking chained function calls

Python – Mocking chained function calls Question: I have the following statement in one of the methods under unit test. db_employees = self.db._session.query(Employee).filter(Employee.dept == new_employee.dept).all() I want db_employees to get mock list of employees. I tried to achieve this using: m = MagickMock() m.return_value.filter().all().return_value = employees where employees is a list of employee object. But …

Total answers: 3