This is an automated email from the ASF dual-hosted git repository.
weilee 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 af7a42ae73c Enable PT001 rule to prvoider tests (#55935)
af7a42ae73c is described below
commit af7a42ae73c48044b49e777cefb79fe78e8b1dde
Author: Xch1 <[email protected]>
AuthorDate: Mon Sep 22 19:03:48 2025 +0800
Enable PT001 rule to prvoider tests (#55935)
---
providers/sftp/tests/unit/sftp/hooks/test_sftp.py | 4 +---
providers/sftp/tests/unit/sftp/operators/test_sftp.py | 2 +-
providers/slack/tests/unit/slack/transfers/test_sql_to_slack.py | 2 +-
providers/snowflake/tests/unit/snowflake/hooks/test_snowflake.py | 3 +--
providers/snowflake/tests/unit/snowflake/hooks/test_sql.py | 3 +--
providers/ssh/tests/unit/ssh/hooks/test_ssh.py | 2 +-
6 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/providers/sftp/tests/unit/sftp/hooks/test_sftp.py
b/providers/sftp/tests/unit/sftp/hooks/test_sftp.py
index b7985566d18..55a9fb9dc62 100644
--- a/providers/sftp/tests/unit/sftp/hooks/test_sftp.py
+++ b/providers/sftp/tests/unit/sftp/hooks/test_sftp.py
@@ -814,11 +814,9 @@ class TestSFTPHookAsync:
)
hook = SFTPHookAsync()
- with pytest.raises(ValueError) as exc:
+ with pytest.raises(ValueError, match="Host key check was skipped, but
`host_key` value was given"):
await hook._get_conn()
- assert str(exc.value) == "Host key check was skipped, but `host_key`
value was given"
-
@patch("paramiko.SSHClient.connect")
@patch("asyncssh.import_private_key")
@patch("asyncssh.connect", new_callable=AsyncMock)
diff --git a/providers/sftp/tests/unit/sftp/operators/test_sftp.py
b/providers/sftp/tests/unit/sftp/operators/test_sftp.py
index fb4c5ed5992..984815fef1a 100644
--- a/providers/sftp/tests/unit/sftp/operators/test_sftp.py
+++ b/providers/sftp/tests/unit/sftp/operators/test_sftp.py
@@ -389,7 +389,7 @@ class TestSFTPOperator:
assert task_3.sftp_hook.remote_host == "remotehost"
def test_unequal_local_remote_file_paths(self):
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="1 paths in local_filepath != 2
paths in remote_filepath"):
SFTPOperator(
task_id="test_sftp_unequal_paths",
local_filepath="/tmp/test",
diff --git a/providers/slack/tests/unit/slack/transfers/test_sql_to_slack.py
b/providers/slack/tests/unit/slack/transfers/test_sql_to_slack.py
index a6daaca07dd..b6c13853c83 100644
--- a/providers/slack/tests/unit/slack/transfers/test_sql_to_slack.py
+++ b/providers/slack/tests/unit/slack/transfers/test_sql_to_slack.py
@@ -148,7 +148,7 @@ class TestSqlToSlackApiFileOperator:
op = SqlToSlackApiFileOperator(
task_id="test_send_file", slack_filename=filename,
**self.default_op_kwargs
)
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="Unsupported file format"):
op.execute(mock.MagicMock())
@mock.patch("airflow.providers.slack.transfers.sql_to_slack.SlackHook")
diff --git a/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake.py
b/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake.py
index fe21b3cad08..1c9e4676daf 100644
--- a/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake.py
+++ b/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake.py
@@ -879,9 +879,8 @@ class TestPytestSnowflakeHook:
hook = SnowflakeHook()
for empty_statement in ([], "", "\n"):
- with pytest.raises(ValueError) as err:
+ with pytest.raises(ValueError, match="List of SQL statements is
empty"):
hook.run(sql=empty_statement)
- assert err.value.args[0] == "List of SQL statements is empty"
def test_get_openlineage_default_schema_with_no_schema_set(self):
connection_kwargs = {
diff --git a/providers/snowflake/tests/unit/snowflake/hooks/test_sql.py
b/providers/snowflake/tests/unit/snowflake/hooks/test_sql.py
index a928c9e288e..ae11cd9fbd6 100644
--- a/providers/snowflake/tests/unit/snowflake/hooks/test_sql.py
+++ b/providers/snowflake/tests/unit/snowflake/hooks/test_sql.py
@@ -244,6 +244,5 @@ def test_query(
def test_no_query(empty_statement):
dbapi_hook = SnowflakeHookForTests()
dbapi_hook.get_conn.return_value.cursor.rowcount = 0
- with pytest.raises(ValueError) as err:
+ with pytest.raises(ValueError, match="List of SQL statements is empty"):
dbapi_hook.run(sql=empty_statement)
- assert err.value.args[0] == "List of SQL statements is empty"
diff --git a/providers/ssh/tests/unit/ssh/hooks/test_ssh.py
b/providers/ssh/tests/unit/ssh/hooks/test_ssh.py
index 1d5fb6408de..52b2fcc86ad 100644
--- a/providers/ssh/tests/unit/ssh/hooks/test_ssh.py
+++ b/providers/ssh/tests/unit/ssh/hooks/test_ssh.py
@@ -598,7 +598,7 @@ class TestSSHHook:
assert
ssh_client.return_value.get_host_keys.return_value.add.called is False
def
test_ssh_connection_with_host_key_where_no_host_key_check_is_true(self):
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="Must check host key when
provided"):
SSHHook(ssh_conn_id=self.CONN_SSH_WITH_HOST_KEY_AND_NO_HOST_KEY_CHECK_TRUE)
@mock.patch("airflow.providers.ssh.hooks.ssh.paramiko.SSHClient")