Skip to content

Commit

Permalink
Add test for calling safe loaded flow with undefined dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
desertaxle committed Jul 29, 2024
1 parent 9fa0c5f commit 140621b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5046,3 +5046,22 @@ def f(
result = safe_load_flow_from_entrypoint(entrypoint)
assert result is not None
assert result().param == 1

def test_raises_name_error_when_loaded_flow_cannot_run(self, tmp_path):
source_code = dedent(
"""
from not_a_module import not_a_function
from prefect import flow
@flow(description="Says woof!")
def dog():
return not_a_function('dog')
"""
)

tmp_path.joinpath("test.py").write_text(source_code)
entrypoint = f"{tmp_path.joinpath('test.py')}:dog"

with pytest.raises(NameError, match="name 'not_a_function' is not defined"):
safe_load_flow_from_entrypoint(entrypoint)()

0 comments on commit 140621b

Please sign in to comment.