This is an automated email from the ASF dual-hosted git repository.
ferruzzi 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 cde63d2b77e Enable PT011 rule to prvoider tests (#56237)
cde63d2b77e is described below
commit cde63d2b77e110d7adf90cd3581b8629eb43c3da
Author: Xch1 <[email protected]>
AuthorDate: Fri Oct 3 02:36:28 2025 +0800
Enable PT011 rule to prvoider tests (#56237)
* fix test_cloud_sql
Signed-off-by: Xch1 <[email protected]>
* fix test_cloud_logging
Signed-off-by: Xch1 <[email protected]>
* fix hooks/test_bigquery
Signed-off-by: Xch1 <[email protected]>
* fix assets/test_gcs
Signed-off-by: Xch1 <[email protected]>
* fix assets/test_bigquery
Signed-off-by: Xch1 <[email protected]>
---------
Signed-off-by: Xch1 <[email protected]>
---
providers/google/tests/unit/google/assets/test_bigquery.py | 2 +-
providers/google/tests/unit/google/assets/test_gcs.py | 2 +-
providers/google/tests/unit/google/cloud/hooks/test_bigquery.py | 4 +---
.../google/tests/unit/google/cloud/hooks/test_cloud_logging.py | 2 +-
providers/google/tests/unit/google/cloud/hooks/test_cloud_sql.py | 6 +++---
5 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/providers/google/tests/unit/google/assets/test_bigquery.py
b/providers/google/tests/unit/google/assets/test_bigquery.py
index acc3adb9ef7..c2f42779444 100644
--- a/providers/google/tests/unit/google/assets/test_bigquery.py
+++ b/providers/google/tests/unit/google/assets/test_bigquery.py
@@ -42,7 +42,7 @@ def test_sanitize_uri_pass() -> None:
)
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 bigquery:// must
contain"):
sanitize_uri(uri_i)
diff --git a/providers/google/tests/unit/google/assets/test_gcs.py
b/providers/google/tests/unit/google/assets/test_gcs.py
index e9920302b0e..9ee93d9f6e3 100644
--- a/providers/google/tests/unit/google/assets/test_gcs.py
+++ b/providers/google/tests/unit/google/assets/test_gcs.py
@@ -33,7 +33,7 @@ def test_sanitize_uri():
def test_sanitize_uri_no_netloc():
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="URI format gs:// must contain"):
sanitize_uri(urllib.parse.urlsplit("gs://"))
diff --git a/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
b/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
index 650eed7a035..9267497af30 100644
--- a/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
+++ b/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
@@ -1550,11 +1550,9 @@ class TestBigQueryAsyncHookMethods:
project_id = "test_project"
location = "US"
- with pytest.raises(Exception) as excinfo:
+ with pytest.raises(Exception, match="Cancellation failed"):
await hook.cancel_job(job_id=job_id, project_id=project_id,
location=location)
- assert "Cancellation failed" in str(excinfo.value), "Exception message
not passed correctly"
-
mock_job_instance.cancel.assert_called_once()
@pytest.mark.asyncio
diff --git
a/providers/google/tests/unit/google/cloud/hooks/test_cloud_logging.py
b/providers/google/tests/unit/google/cloud/hooks/test_cloud_logging.py
index afaea5185ff..d4d83088a00 100644
--- a/providers/google/tests/unit/google/cloud/hooks/test_cloud_logging.py
+++ b/providers/google/tests/unit/google/cloud/hooks/test_cloud_logging.py
@@ -160,7 +160,7 @@ class TestCloudLoggingHook:
mock_config_client.return_value.create_sink.assert_called_once_with(request=expected_request)
def test_update_sink_invalid_dict_format(self):
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="Unknown field for LogSink:
invalid_key"):
self.hook.update_sink(
sink_name=SINK_NAME,
sink={"invalid_key": "value"},
diff --git a/providers/google/tests/unit/google/cloud/hooks/test_cloud_sql.py
b/providers/google/tests/unit/google/cloud/hooks/test_cloud_sql.py
index f1a332eb4fb..52d1190fbc3 100644
--- a/providers/google/tests/unit/google/cloud/hooks/test_cloud_sql.py
+++ b/providers/google/tests/unit/google/cloud/hooks/test_cloud_sql.py
@@ -974,10 +974,10 @@ class TestCloudSqlDatabaseHook:
hook = CloudSQLDatabaseHook(
gcp_cloudsql_conn_id="cloudsql_connection",
default_gcp_project_id="google_connection"
)
- with pytest.raises(ValueError) as ctx:
+ with pytest.raises(
+ ValueError, match="Proxy runner can only be retrieved in case of
use_proxy = True"
+ ):
hook.get_sqlproxy_runner()
- err = ctx.value
- assert "Proxy runner can only be retrieved in case of use_proxy =
True" in str(err)
@mock.patch("airflow.providers.google.cloud.hooks.cloud_sql.CloudSQLDatabaseHook.get_connection")
def test_cloudsql_database_hook_get_sqlproxy_runner(self, get_connection):