def test_children(self): x = AsyncResult('1') children = [EagerResult(str(i), i, states.SUCCESS) for i in range(3)] x.backend = Mock() x.backend.get_children.return_value = children x.backend.READY_STATES = states.READY_STATES self.assertTrue(x.children) self.assertEqual(len(x.children), 3)
def disable_async_result(result: AsyncResult): # fetching the children could itself result in using the backend. So we disable it before hand result.backend = None try: children = result.children or [] except AttributeError: return for child in children: disable_async_result(child)