The page you navigated to () does not exist, so we brought you to the closest page to it.
You have switched from the to the variant of this site. There is no equivalent of . We have taken you to the closest page in the variant.
1.16.16
flytekit.core.testing
Directory
Methods
| Method | Description |
|---|---|
patch() |
This is a decorator used for testing. |
task_mock() |
Use this method to mock a task declaration. |
Methods
patch()
def patch(
target: typing.Union[flytekit.core.base_task.PythonTask, flytekit.core.workflow.WorkflowBase, flytekit.core.reference_entity.ReferenceEntity],
)This is a decorator used for testing.
| Parameter | Type | Description |
|---|---|---|
target |
typing.Union[flytekit.core.base_task.PythonTask, flytekit.core.workflow.WorkflowBase, flytekit.core.reference_entity.ReferenceEntity] |
task_mock()
def task_mock(
t: flytekit.core.base_task.PythonTask,
) -> typing.Generator[unittest.mock.MagicMock, NoneType, NoneType]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:
```python
@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
```
| Parameter | Type | Description |
|---|---|---|
t |
flytekit.core.base_task.PythonTask |