flytekit.testing.task_mock#
- flytekit.testing.task_mock(t)[source]#
Use this method to mock a task declaration. It can mock any Task in Flytekit as long as it has a python native interface associated with it.
The returned object is a MagicMock and allows to perform all such methods. This MagicMock, mocks the execute method on the PythonTask
Usage:
@task def t1(i: int) -> int: pass with task_mock(t1) as m: m.side_effect = lambda x: x t1(10) # The mock is valid only within this context
- Parameters:
t (PythonTask)
- Return type: