Nimesh Kumar
02/24/2025, 1:11 PMpytest
module, and the way to fake the Prefect server during unit tests is described here.
When I use that code with Prefect 2.7.7, I get this error:
E TypeError: AsyncClient.__init__() got an unexpected keyword argument 'app'
../env/lib/python3.10/site-packages/prefect/client/orion.py:183: TypeError
_This error disappears after I remove the code mentioning the prefect_test_harness
, and start the prefect server. I can see in the Prefect UI that flows and tasks were created for the unit test. I don't think that's desirable; we would like to run unit tests in CI without the need for a prefect server._
_The other way I can get that code to run, is to stop the prefect server, enable the code using the prefect_test_harness
, and create a new virtual env with prefect 2.20.16. In that case, the tests run as expected._
It seems to me that the dated Prefect version is to blame. Is there any way we can do this in prefect 2.7.7 or do we need toi upgrade to the latest prefect version ?
orion-docs.prefect.io
Testing - Prefect 2 - Coordinating the world's dataflows
Learn about writing tests for Prefect flows and tasks.