Hey all, anyone had issues just running the most b...
# ask-community
k
Hey all, anyone had issues just running the most basic test with prefect?
Copy code
from prefect import flow
from prefect.testing.utilities import prefect_test_harness


@flow
def my_favorite_flow():
    return 42


def test_my_favorite_flow():
    with prefect_test_harness(server_startup_timeout=120):
        assert my_favorite_flow() == 42
I seem to be unable to make it work, I always get a 'timeout':
Copy code
pytest tests/test_dummy.py 
=============================================================================================================================== test session starts ===============================================================================================================================
platform linux -- Python 3.10.12, pytest-7.4.4, pluggy-1.6.0
rootdir: /workspace
configfile: pytest.ini
plugins: devtools-0.12.2, docker-3.2.3, anyio-4.11.0, asyncio-0.23.8, xdist-3.8.0, postgresql-7.0.2, dash-3.2.0, hydra-core-1.3.2, Faker-37.8.0, cov-6.2.1
asyncio: mode=strict
collected 1 item                                                                                                                                                                                                                                                                  

tests/test_dummy.py 
F                                                                                                                                                                                                    [100%]

== FAILURES ==
__ test_my_favorite_flow __

    def test_my_favorite_flow():
>       with prefect_test_harness(server_startup_timeout=120):

tests/test_dummy.py:11: 
 _ _
/usr/lib/python3.10/contextlib.py:135: in __enter__
    return next(self.gen)
...py310/lib/python3.10/site-packages/prefect/testing/utilities.py:168: in prefect_test_harness
    test_server.start(
 _ _

self = <prefect.server.api.server.SubprocessASGIServer object at 0x77ee36386200>, timeout = 120

    def start(self, timeout: Optional[int] = None) -> None:
        ...
>                       raise RuntimeError(error_message)
E                       RuntimeError: Timed out while attempting to connect to ephemeral Prefect API server.

...py310/lib/python3.10/site-packages/prefect/server/api/server.py:921: RuntimeError
-- Captured stderr call --
13:49:16.879 | INFO    | prefect - Starting temporary server on <http://127.0.0.1:8787>
See <https://docs.prefect.io/v3/concepts/server#how-to-guides> for more information on running a dedicated Prefect server.
-- Captured log call --
INFO     prefect:server.py:881 Starting temporary server on <http://127.0.0.1:8787>
See <https://docs.prefect.io/v3/concepts/server#how-to-guides> for more information on running a dedicated Prefect server.