This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-10-test by this push:
     new d7d8814e4a Simpler task retrieval for taskinstance test (#41389) 
(#41953)
d7d8814e4a is described below

commit d7d8814e4ae920813b19341b3c3bc314233f81f0
Author: Ephraim Anierobi <splendidzig...@gmail.com>
AuthorDate: Mon Sep 2 14:05:28 2024 +0100

    Simpler task retrieval for taskinstance test (#41389) (#41953)
    
    The test has been updated for DB isolation but the retrieval of
    task was not intuitive and it could lead to flaky tests possibly
    
    (cherry picked from commit f25adf14ad486bac818fe3fdcd61eb3355e8ec9b)
    
    Co-authored-by: Jarek Potiuk <ja...@potiuk.com>
---
 tests/models/test_taskinstance.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/models/test_taskinstance.py 
b/tests/models/test_taskinstance.py
index ba5ac7c7b5..fbbf175ddd 100644
--- a/tests/models/test_taskinstance.py
+++ b/tests/models/test_taskinstance.py
@@ -1540,8 +1540,9 @@ class TestTaskInstance:
         monkeypatch.setattr(_UpstreamTIStates, "calculate", lambda *_: 
upstream_states)
         ti = dr.get_task_instance("do_something_else", session=session)
         ti.map_index = 0
+        base_task = ti.task
         for map_index in range(1, 5):
-            ti = TaskInstance(dr.task_instances[-1].task, run_id=dr.run_id, 
map_index=map_index)
+            ti = TaskInstance(base_task, run_id=dr.run_id, map_index=map_index)
             session.add(ti)
             ti.dag_run = dr
         session.flush()

Reply via email to