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

henry3260 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 8ef0880a214 Collect the test classes pytest silently skipped (#71643)
8ef0880a214 is described below

commit 8ef0880a2142d09e50d0766b3d87f3c5ce1291b6
Author: PoAn Yang <[email protected]>
AuthorDate: Thu Aug 20 05:58:28 2026 +0900

    Collect the test classes pytest silently skipped (#71643)
    
    Signed-off-by: PoAn Yang <[email protected]>
---
 .../tests/unit/apache/hive/operators/test_hive.py  | 31 ++++++++++++----------
 .../unit/google/cloud/sensors/test_bigtable.py     | 17 +++++++++---
 2 files changed, 31 insertions(+), 17 deletions(-)

diff --git 
a/providers/apache/hive/tests/unit/apache/hive/operators/test_hive.py 
b/providers/apache/hive/tests/unit/apache/hive/operators/test_hive.py
index 70927a7f066..e7e40c5ec92 100644
--- a/providers/apache/hive/tests/unit/apache/hive/operators/test_hive.py
+++ b/providers/apache/hive/tests/unit/apache/hive/operators/test_hive.py
@@ -22,7 +22,7 @@ from unittest import mock
 
 import pytest
 
-from airflow.models import DagRun, TaskInstance
+from airflow.models import TaskInstance
 from airflow.providers.apache.hive.operators.hive import HiveOperator
 from airflow.providers.common.compat.sdk import conf, timezone
 
@@ -36,8 +36,10 @@ def get_hive_cli_connection():
     return connection
 
 
-class HiveOperatorConfigTest(TestHiveEnvironment):
-    def test_hive_airflow_default_config_queue(self):
+class TestHiveOperatorConfig(TestHiveEnvironment):
+    
@mock.patch("airflow.providers.apache.hive.hooks.hive.HiveCliHook.get_connection")
+    def test_hive_airflow_default_config_queue(self, mock_get_connection):
+        mock_get_connection.return_value = get_hive_cli_connection()
         op = HiveOperator(
             task_id="test_default_config_queue",
             hql=self.hql,
@@ -50,7 +52,9 @@ class HiveOperatorConfigTest(TestHiveEnvironment):
         test_config_hive_mapred_queue = conf.get("hive", 
"default_hive_mapred_queue")
         assert op.hook.mapred_queue == test_config_hive_mapred_queue
 
-    def test_hive_airflow_default_config_queue_override(self):
+    
@mock.patch("airflow.providers.apache.hive.hooks.hive.HiveCliHook.get_connection")
+    def test_hive_airflow_default_config_queue_override(self, 
mock_get_connection):
+        mock_get_connection.return_value = get_hive_cli_connection()
         specific_mapred_queue = "default"
         op = HiveOperator(
             task_id="test_default_config_queue",
@@ -80,7 +84,7 @@ class TestHiveOperatorJdbcParams(TestHiveEnvironment):
         assert op.hook.jdbc_params == jdbc_params
 
 
-class HiveOperatorTest(TestHiveEnvironment):
+class TestHiveOperator(TestHiveEnvironment):
     def test_hiveconf_jinja_translate(self):
         hql = "SELECT ${num_col} FROM ${hiveconf:table};"
         op = HiveOperator(hiveconf_jinja_translate=True, 
task_id="dry_run_basic_hql", hql=hql, dag=self.dag)
@@ -99,21 +103,20 @@ class HiveOperatorTest(TestHiveEnvironment):
         assert op.hql == "SELECT * FROM ${hiveconf:table} PARTITION 
(${hiveconf:day});"
 
     
@mock.patch("airflow.providers.apache.hive.operators.hive.HiveOperator.hook", 
mock.MagicMock())
-    def test_mapred_job_name(self, mock_hook):
+    def test_mapred_job_name(self):
         op = HiveOperator(task_id="test_mapred_job_name", hql=self.hql, 
dag=self.dag)
 
-        fake_run_id = "test_mapred_job_name"
         fake_logical_date = timezone.datetime(2018, 6, 19)
-        fake_ti = TaskInstance(task=op)
-        fake_ti.dag_run = DagRun(run_id=fake_run_id, 
logical_date=fake_logical_date)
-        fake_ti.hostname = "fake_hostname"
-        fake_context = {"ti": fake_ti}
+        fake_ti = mock.MagicMock(
+            spec=TaskInstance, dag_id=self.dag.dag_id, task_id=op.task_id, 
hostname="fake_hostname"
+        )
+        fake_context = {"ti": fake_ti, "logical_date": fake_logical_date}
 
         op.execute(fake_context)
-        assert (
+
+        assert op.hook.mapred_job_name == (
             "Airflow HiveOperator task for "
-            
f"{fake_ti.hostname}.{self.dag.dag_id}.{op.task_id}.{fake_logical_date.isoformat()}"
-            == mock_hook.mapred_job_name
+            
f"fake_hostname.{self.dag.dag_id}.{op.task_id}.{fake_logical_date.isoformat()}"
         )
 
 
diff --git a/providers/google/tests/unit/google/cloud/sensors/test_bigtable.py 
b/providers/google/tests/unit/google/cloud/sensors/test_bigtable.py
index 0eba204dac2..776582e07d9 100644
--- a/providers/google/tests/unit/google/cloud/sensors/test_bigtable.py
+++ b/providers/google/tests/unit/google/cloud/sensors/test_bigtable.py
@@ -25,8 +25,11 @@ from google.cloud.bigtable.instance import Instance
 from google.cloud.bigtable.table import ClusterState
 
 from airflow.providers.common.compat.sdk import AirflowException
+from airflow.providers.google.cloud.links.bigtable import BigtableTablesLink
 from airflow.providers.google.cloud.sensors.bigtable import 
BigtableTableReplicationCompletedSensor
 
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
 PROJECT_ID = "test_project_id"
 INSTANCE_ID = "test-instance-id"
 GCP_CONN_ID = "test-gcp-conn-id"
@@ -34,7 +37,7 @@ TABLE_ID = "test-table-id"
 IMPERSONATION_CHAIN = ["ACCOUNT_1", "ACCOUNT_2", "ACCOUNT_3"]
 
 
-class BigtableWaitForTableReplicationTest:
+class TestBigtableWaitForTableReplication:
     @pytest.mark.parametrize(
         ("missing_attribute", "project_id", "instance_id", "table_id"),
         [
@@ -43,7 +46,7 @@ class BigtableWaitForTableReplicationTest:
         ],
     )
     @mock.patch("airflow.providers.google.cloud.sensors.bigtable.BigtableHook")
-    def test_empty_attribute(self, missing_attribute, project_id, instance_id, 
table_id, mock_hook):
+    def test_empty_attribute(self, mock_hook, missing_attribute, project_id, 
instance_id, table_id):
         with pytest.raises(AirflowException) as ctx:
             BigtableTableReplicationCompletedSensor(
                 project_id=project_id,
@@ -126,8 +129,16 @@ class BigtableWaitForTableReplicationTest:
             gcp_conn_id=GCP_CONN_ID,
             impersonation_chain=IMPERSONATION_CHAIN,
         )
-        assert op.poke(None)
+        ti = mock.MagicMock()
+
+        assert op.poke({"ti": ti, "task": op})
+
         mock_hook.assert_called_once_with(
             gcp_conn_id=GCP_CONN_ID,
             impersonation_chain=IMPERSONATION_CHAIN,
         )
+        # Only this path reaches BigtableTablesLink.persist, which does 
context["ti"].xcom_push().
+        ti.xcom_push.assert_called_once_with(
+            key=BigtableTablesLink.key,
+            value={} if AIRFLOW_V_3_0_PLUS else {"instance_id": INSTANCE_ID, 
"project_id": PROJECT_ID},
+        )

Reply via email to