Philip MacMenamin
12/22/2021, 3:19 PMAnna Geller
Philip MacMenamin
12/22/2021, 4:28 PMPhilip MacMenamin
12/22/2021, 4:31 PMdef test_single_file_not_found_gens_exception(monkeypatch):
with pytest.raises(signals.FAIL):
flow.run(input_dir=os.getcwd() + "/test/input_files/",
file_name="does_not_exist")
Philip MacMenamin
12/22/2021, 4:33 PMprefect.TaskRunner | FAIL signal raised: FAIL('Expecting file: does_not_exist, not found in input_dir')
Philip MacMenamin
12/22/2021, 4:33 PMDID NOT RAISE <class 'prefect.engine.signals.FAIL'>
So, I thought maybe I should test the Task rather than run the flow.Philip MacMenamin
12/22/2021, 5:42 PMdef test_single_file_not_found_gens_exception(mock_nfs_mount):
state = flow.run(input_dir=os.getcwd() + "/test/input_files/",
file_name="does_not_exist")
assert state.is_failed()
It would nice if there was a clear example how you can test run a task, or a flow, to generate an exception.Anna Geller