Jai P
04/20/2022, 12:58 AMZanie
04/20/2022, 1:07 AMJai P
04/20/2022, 1:26 AMpytest
==================================================================================== test session starts =====================================================================================
platform darwin -- Python 3.10.2, pytest-7.1.1, pluggy-1.0.0
rootdir: /path/to/dir
plugins: anyio-3.5.0
collected 10 items
tests/test_flow.py .......... [100%]
==================================================================================== 10 passed in 11.09s =====================================================================================
Zanie
04/20/2022, 1:35 AMJai P
04/20/2022, 1:41 AMexpose this in the near futureyou're talking about the higher performance lower level reset? the session scope is just a pytest change right?
Zanie
04/20/2022, 1:44 AMJai P
04/20/2022, 1:49 AMZanie
04/20/2022, 1:52 AMmy_flow.test(...)
returns a TestResult
object that gives you full introspection of all of the task and flow runs that it created, their states, number of retries, return values, etc. so you can make the assertions you want.prefect_test_harness
per test is slow”Marvin
04/20/2022, 1:53 AMJai P
04/20/2022, 1:59 AMdavzucky
04/20/2022, 12:31 PMZanie
04/20/2022, 2:40 PMDanny Sepler
04/20/2022, 6:00 PM# my_task.py
from prefect import task
@task
def double_value(value: int) -> int:
return value * 2
# test_my_task.py
from my_task import double_value
def test_double_value():
assert double_value.__wrapped__(1) == 2
is this an ok approach? would it make sense to make a lil helper function for this? if this is ok, i could add it to your testing docs!Zanie
04/20/2022, 6:08 PMdouble_value.fn(1)
Danny Sepler
04/20/2022, 7:39 PM.fn()
is even clearer than wrapped. thanks! yeah a few of our tasks won't rely on prefect behavior, so this is nice for those
could be a nice addition to these docs, if you'd like me to diff it in?Zanie
04/20/2022, 8:18 PMdavzucky
04/20/2022, 10:57 PM