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

jasonliu 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 2afb30dbfe9 Enable PT011 rule to prvoider tests (#56021)
2afb30dbfe9 is described below

commit 2afb30dbfe94c38e689af9b305777336ea894981
Author: Xch1 <[email protected]>
AuthorDate: Thu Sep 25 12:19:35 2025 +0800

    Enable PT011 rule to prvoider tests (#56021)
    
    * modify test_conf
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_openai
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_mysql
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_data_factory
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_commands
    
    Signed-off-by: Xch1 <[email protected]>
    
    ---------
    
    Signed-off-by: Xch1 <[email protected]>
---
 .../tests/unit/keycloak/auth_manager/cli/test_commands.py        | 2 +-
 .../azure/tests/unit/microsoft/azure/hooks/test_data_factory.py  | 8 ++++++--
 providers/mysql/tests/unit/mysql/assets/test_mysql.py            | 9 +++++++--
 providers/openai/tests/unit/openai/operators/test_openai.py      | 5 ++++-
 providers/openlineage/tests/unit/openlineage/test_conf.py        | 2 +-
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git 
a/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py 
b/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py
index d04a1dd3e35..4ead9a3ef68 100644
--- a/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py
+++ b/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py
@@ -107,7 +107,7 @@ class TestCommands:
                 ("keycloak_auth_manager", "client_id"): "test_client_id",
             }
         ):
-            with pytest.raises(ValueError):
+            with pytest.raises(ValueError, match="Client with 
ID='test_client_id' not found in realm"):
                 create_scopes_command(self.arg_parser.parse_args(params))
 
         client.get_clients.assert_called_once_with()
diff --git 
a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py
 
b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py
index 52fbca929da..a0c3a74304d 100644
--- 
a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py
+++ 
b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py
@@ -797,7 +797,9 @@ class TestAzureDataFactoryAsyncHook:
     async def test_get_async_conn_key_error_subscription_id(self, 
mocked_connection):
         """Test get_async_conn function when subscription_id is missing in the 
connection"""
         hook = AzureDataFactoryAsyncHook(mocked_connection.conn_id)
-        with pytest.raises(ValueError):
+        with pytest.raises(
+            ValueError, match="A Subscription ID is required to connect to 
Azure Data Factory."
+        ):
             await hook.get_async_conn()
 
     @pytest.mark.asyncio
@@ -821,7 +823,9 @@ class TestAzureDataFactoryAsyncHook:
     async def test_get_async_conn_key_error_tenant_id(self, mocked_connection):
         """Test get_async_conn function when tenant id is missing in the 
connection"""
         hook = AzureDataFactoryAsyncHook(mocked_connection.conn_id)
-        with pytest.raises(ValueError):
+        with pytest.raises(
+            ValueError, match="A Tenant ID is required when authenticating 
with Client ID and Secret."
+        ):
             await hook.get_async_conn()
 
     def test_get_field_prefixed_extras(self):
diff --git a/providers/mysql/tests/unit/mysql/assets/test_mysql.py 
b/providers/mysql/tests/unit/mysql/assets/test_mysql.py
index 28e44558f31..733c4eb097a 100644
--- a/providers/mysql/tests/unit/mysql/assets/test_mysql.py
+++ b/providers/mysql/tests/unit/mysql/assets/test_mysql.py
@@ -56,11 +56,16 @@ def test_sanitize_uri_pass(original: str, normalized: str) 
-> None:
         pytest.param("mysql://", id="blank"),
         pytest.param("mysql:///database/table", id="no-host"),
         pytest.param("mysql://example.com/database", id="missing-component"),
-        pytest.param("mysql://example.com:abcd/database/table", id="non-port"),
         pytest.param("mysql://example.com/database/table/column", 
id="extra-component"),
     ],
 )
 def test_sanitize_uri_fail(value: str) -> None:
     uri_i = urllib.parse.urlsplit(value)
-    with pytest.raises(ValueError):
+    with pytest.raises(ValueError, match="URI format mysql:// must contain"):
+        sanitize_uri(uri_i)
+
+
+def test_sanitize_uri_fail_non_port() -> None:
+    uri_i = urllib.parse.urlsplit("mysql://example.com:abcd/database/table")
+    with pytest.raises(ValueError, match="Port could not be cast to integer 
value as 'abcd'"):
         sanitize_uri(uri_i)
diff --git a/providers/openai/tests/unit/openai/operators/test_openai.py 
b/providers/openai/tests/unit/openai/operators/test_openai.py
index e160163db85..6b582b6d9fe 100644
--- a/providers/openai/tests/unit/openai/operators/test_openai.py
+++ b/providers/openai/tests/unit/openai/operators/test_openai.py
@@ -72,7 +72,10 @@ def test_execute_with_invalid_input(invalid_input):
         task_id=TASK_ID, conn_id=CONN_ID, model="test_model", 
input_text=invalid_input
     )
     context = Context()
-    with pytest.raises(ValueError):
+    with pytest.raises(
+        ValueError,
+        match="The 'input_text' must be a non-empty string, list of strings, 
list of integers, or list of lists of integers.",
+    ):
         operator.execute(context)
 
 
diff --git a/providers/openlineage/tests/unit/openlineage/test_conf.py 
b/providers/openlineage/tests/unit/openlineage/test_conf.py
index c8b5441fd4d..6cea702afcb 100644
--- a/providers/openlineage/tests/unit/openlineage/test_conf.py
+++ b/providers/openlineage/tests/unit/openlineage/test_conf.py
@@ -320,7 +320,7 @@ def test_transport_valid():
 @pytest.mark.parametrize("transport_value", ('["a", "b"]', "[]", '[{"a": 
"b"}]'))
 def test_transport_not_valid(transport_value):
     with conf_vars({(_CONFIG_SECTION, _CONFIG_OPTION_TRANSPORT): 
transport_value}):
-        with pytest.raises(ValueError):
+        with pytest.raises(ValueError, match="OpenLineage transport"):
             transport()
 
 

Reply via email to