for the testing flows example (<https://docs.prefe...
# prefect-community
for the testing flows example (, is there an equivalent example for using the
Copy code
with Flow() as flow:
   e = Extract()
   t = Transform(e)
   l = Load(t)
state =
syntax? I'm getting key not found results on asserting state.result[e], and wondering if you have to do it in the way given in the testing-flows link above to unit test the flows.
I'm wondering if you have to explicitly build the dag as the example code shows in order to explicitly test things.
Hi @Dolor Oculus I don’t think there’s any reason you’d need to follow a particular syntax when testing - can you share a minimum reproducible example of what you’re seeing?
Hi, I was probably doing something dumb. Here's a repro that works perfectly
Copy code
def test_simple_flow():
    def extract():
        return 42

    def transform(x: int) -> int:
        return int(x / 2 + 2)

    def load(x: int) -> str:
        return str(x)

    with Flow(__name__, environment=LocalEnvironment()) as flow:
        e = extract()
        t = transform(e)
        l = load(t)

    state =
    assert state.is_successful()

    assert state.result[e].is_successful()
    assert state.result[t].is_successful()
    assert state.result[l].is_successful()

    assert state.result[e].result == 42
    assert state.result[t].result == 23
    assert state.result[l].result == "23"
Happens to the best of us!