https://prefect.io logo
#prefect-community
Title
# prefect-community
a

Andrew Miller

07/28/2022, 6:22 PM
How do we unit test tasks and flows in Prefect 2.0? I am getting the following error on my test cases after upgrading.
Tasks cannot be run outside of a flow. To call the underlying task function outside of a flow use
task.fn()
I tried
with prefect_test_harness():
but no luck... Ah. Never mind, I should have been reading the error more. Calling
fn
instead of
run
fixes old test cases.
1
n

Nate

07/28/2022, 6:26 PM
there are some great examples that live in our numerous collections repos, like this one
5 Views