diff --git a/providers/standard/tests/unit/standard/triggers/test_file.py b/providers/standard/tests/unit/standard/triggers/test_file.py index 2d5a52eaf151f..793f0aeb62861 100644 --- a/providers/standard/tests/unit/standard/triggers/test_file.py +++ b/providers/standard/tests/unit/standard/triggers/test_file.py @@ -60,12 +60,11 @@ async def test_task_file_trigger(self, tmp_path): p.touch() - await asyncio.sleep(0.5) + # Await the task directly so the assertion can't race the trigger's + # detect → yield cycle on slow runners (ARM, Pendulum2 special job). + await asyncio.wait_for(task, timeout=5.0) assert task.done() is True - # Prevents error when task is destroyed while in "pending" state - asyncio.get_event_loop().stop() - @pytest.mark.skipif(not AIRFLOW_V_3_0_PLUS, reason="Skip on Airflow < 3.0") class TestFileDeleteTrigger: @@ -101,8 +100,9 @@ async def test_file_delete_trigger(self, tmp_path): p.touch() - await asyncio.sleep(0.5) + # Await the task directly so the assertion can't race the trigger's + # detect → unlink → yield cycle on slow runners (ARM, Pendulum2 + # special job). The trigger only yields after `await filepath.unlink()` + # returns, so once the task is done, the file is guaranteed gone. + await asyncio.wait_for(task, timeout=5.0) assert await anyio.Path(p).exists() is False - - # Prevents error when task is destroyed while in "pending" state - asyncio.get_event_loop().stop()