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

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 60cbea5097 Fix pytests for Core except Variable for DB Isolation Mode 
(#41375)
60cbea5097 is described below

commit 60cbea509707a4390ea9ea4239c737f0a44e8aea
Author: Jens Scheffler <[email protected]>
AuthorDate: Sun Aug 11 20:07:13 2024 +0200

    Fix pytests for Core except Variable for DB Isolation Mode (#41375)
---
 tests/models/test_trigger.py                           |  5 +++++
 tests/models/test_xcom_arg.py                          |  1 +
 tests/models/test_xcom_arg_map.py                      |  8 ++++++++
 tests/utils/test_task_handler_with_custom_formatter.py | 12 ++++++------
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/tests/models/test_trigger.py b/tests/models/test_trigger.py
index 5a8ef28df0..4aa5b8b581 100644
--- a/tests/models/test_trigger.py
+++ b/tests/models/test_trigger.py
@@ -99,6 +99,7 @@ def test_clean_unused(session, create_task_instance):
     assert session.query(Trigger).one().id == trigger1.id
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_submit_event(session, create_task_instance):
     """
     Tests that events submitted to a trigger re-wake their dependent
@@ -126,6 +127,7 @@ def test_submit_event(session, create_task_instance):
     assert updated_task_instance.next_kwargs == {"event": 42, "cheesecake": 
True}
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_submit_failure(session, create_task_instance):
     """
     Tests that failures submitted to a trigger fail their dependent
@@ -150,6 +152,7 @@ def test_submit_failure(session, create_task_instance):
     assert updated_task_instance.next_method == "__fail__"
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 @pytest.mark.parametrize(
     "event_cls, expected",
     [
@@ -300,6 +303,7 @@ def test_assign_unassigned(session, create_task_instance):
     )
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_get_sorted_triggers_same_priority_weight(session, 
create_task_instance):
     """
     Tests that triggers are sorted by the creation_date if they have the same 
priority.
@@ -350,6 +354,7 @@ def test_get_sorted_triggers_same_priority_weight(session, 
create_task_instance)
     assert trigger_ids_query == [(1,), (2,)]
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_get_sorted_triggers_different_priority_weights(session, 
create_task_instance):
     """
     Tests that triggers are sorted by the priority_weight.
diff --git a/tests/models/test_xcom_arg.py b/tests/models/test_xcom_arg.py
index 2652a1032b..6108c5e819 100644
--- a/tests/models/test_xcom_arg.py
+++ b/tests/models/test_xcom_arg.py
@@ -184,6 +184,7 @@ class TestXComArgRuntime:
         dag.run()
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 @pytest.mark.parametrize(
     "fillvalue, expected_results",
     [
diff --git a/tests/models/test_xcom_arg_map.py 
b/tests/models/test_xcom_arg_map.py
index b2e885e940..26df335215 100644
--- a/tests/models/test_xcom_arg_map.py
+++ b/tests/models/test_xcom_arg_map.py
@@ -29,6 +29,7 @@ from airflow.utils.trigger_rule import TriggerRule
 pytestmark = pytest.mark.db_test
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_map(dag_maker, session):
     results = set()
     with dag_maker(session=session) as dag:
@@ -64,6 +65,7 @@ def test_xcom_map(dag_maker, session):
     assert results == {"aa", "bb", "cc"}
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_map_transform_to_none(dag_maker, session):
     results = set()
 
@@ -98,6 +100,7 @@ def test_xcom_map_transform_to_none(dag_maker, session):
     assert results == {"a", "b", None}
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_convert_to_kwargs_fails_task(dag_maker, session):
     results = set()
 
@@ -145,6 +148,7 @@ def test_xcom_convert_to_kwargs_fails_task(dag_maker, 
session):
     ]
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_map_error_fails_task(dag_maker, session):
     with dag_maker(session=session) as dag:
 
@@ -241,6 +245,7 @@ def test_task_map_variant():
     assert task_map.variant == TaskMapVariant.DICT
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_map_raise_to_skip(dag_maker, session):
     result = None
 
@@ -285,6 +290,7 @@ def test_xcom_map_raise_to_skip(dag_maker, session):
     assert result == ["a", "b"]
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_map_nest(dag_maker, session):
     results = set()
 
@@ -318,6 +324,7 @@ def test_xcom_map_nest(dag_maker, session):
     assert results == {"aa", "bb", "cc"}
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_map_zip_nest(dag_maker, session):
     results = set()
 
@@ -364,6 +371,7 @@ def test_xcom_map_zip_nest(dag_maker, session):
     assert results == {"aa", "bbbb", "cccccc", "dddddddd"}
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 def test_xcom_concat(dag_maker, session):
     from airflow.models.xcom_arg import _ConcatResult
 
diff --git a/tests/utils/test_task_handler_with_custom_formatter.py 
b/tests/utils/test_task_handler_with_custom_formatter.py
index c6c6565f54..9eb183c6be 100644
--- a/tests/utils/test_task_handler_with_custom_formatter.py
+++ b/tests/utils/test_task_handler_with_custom_formatter.py
@@ -22,7 +22,6 @@ import logging
 import pytest
 
 from airflow.config_templates.airflow_local_settings import 
DEFAULT_LOGGING_CONFIG
-from airflow.models.dag import DAG
 from airflow.models.taskinstance import TaskInstance
 from airflow.operators.empty import EmptyOperator
 from airflow.utils.log.logging_mixin import set_context
@@ -59,11 +58,11 @@ def custom_task_log_handler_config():
 
 
 @pytest.fixture
-def task_instance():
-    dag = DAG(DAG_ID, start_date=DEFAULT_DATE)
-    task = EmptyOperator(task_id=TASK_ID, dag=dag)
-    dagrun = dag.create_dagrun(
-        DagRunState.RUNNING,
+def task_instance(dag_maker):
+    with dag_maker(DAG_ID, start_date=DEFAULT_DATE, serialized=True) as dag:
+        task = EmptyOperator(task_id=TASK_ID)
+    dagrun = dag_maker.create_dagrun(
+        state=DagRunState.RUNNING,
         execution_date=DEFAULT_DATE,
         run_type=DagRunType.MANUAL,
         
data_interval=dag.timetable.infer_manual_data_interval(run_after=DEFAULT_DATE),
@@ -103,6 +102,7 @@ def test_custom_formatter_default_format(task_instance):
     assert_prefix_once(task_instance, "")
 
 
[email protected]_if_database_isolation_mode  # Does not work in db isolation 
mode
 @conf_vars({("logging", "task_log_prefix_template"): "{{ ti.dag_id }}-{{ 
ti.task_id }}"})
 def test_custom_formatter_custom_format_not_affected_by_config(task_instance):
     """Certifies that the prefix is only added once, even after repeated 
calls"""

Reply via email to