This is an automated email from the ASF dual-hosted git repository.
uranusjr 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 dd3d5317106 Enable PT011 rule to prvoider tests (#56929)
dd3d5317106 is described below
commit dd3d5317106ce62801fbe3926946a05c24e1a8c7
Author: Xch1 <[email protected]>
AuthorDate: Wed Oct 29 12:27:14 2025 +0800
Enable PT011 rule to prvoider tests (#56929)
---
.../unit/tests_common/test_utils/test_stream_capture_manager.py | 2 +-
providers/amazon/tests/unit/amazon/aws/assets/test_s3.py | 2 +-
.../tests/unit/amazon/aws/executors/batch/test_batch_executor.py | 4 +---
.../amazon/tests/unit/amazon/aws/executors/ecs/test_ecs_executor.py | 6 ++----
providers/standard/tests/unit/standard/operators/test_hitl.py | 2 +-
5 files changed, 6 insertions(+), 10 deletions(-)
diff --git
a/devel-common/tests/unit/tests_common/test_utils/test_stream_capture_manager.py
b/devel-common/tests/unit/tests_common/test_utils/test_stream_capture_manager.py
index 880734727bb..26db64be497 100644
---
a/devel-common/tests/unit/tests_common/test_utils/test_stream_capture_manager.py
+++
b/devel-common/tests/unit/tests_common/test_utils/test_stream_capture_manager.py
@@ -463,7 +463,7 @@ def
test_exception_during_capture_with_pytest_raises(stdout_capture):
assert "Log before exception" not in output
# Now test that exception in capture context still works
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="Test exception"):
with stdout_capture:
raise ValueError("Test exception")
diff --git a/providers/amazon/tests/unit/amazon/aws/assets/test_s3.py
b/providers/amazon/tests/unit/amazon/aws/assets/test_s3.py
index e918c9fdffa..b5a90ed1c03 100644
--- a/providers/amazon/tests/unit/amazon/aws/assets/test_s3.py
+++ b/providers/amazon/tests/unit/amazon/aws/assets/test_s3.py
@@ -38,7 +38,7 @@ def test_sanitize_uri():
def test_sanitize_uri_no_netloc():
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="URI format s3:// must contain a
bucket name"):
sanitize_uri(urllib.parse.urlsplit("s3://"))
diff --git
a/providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor.py
b/providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor.py
index 1e8e08eccef..1098efac777 100644
---
a/providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor.py
+++
b/providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor.py
@@ -744,11 +744,9 @@ class TestBatchExecutorConfig:
],
)
def test_executor_config_exceptions(self, bad_config, mock_executor):
- with pytest.raises(ValueError) as raised:
+ with pytest.raises(ValueError, match='Executor Config should never
override "command'):
mock_executor.execute_async(mock_airflow_key, mock_cmd,
executor_config=bad_config)
- assert raised.match('Executor Config should never override "command')
-
def test_config_defaults_are_applied(self):
submit_kwargs = batch_executor_config.build_submit_kwargs()
found_keys = {convert_camel_to_snake(key): key for key in
submit_kwargs.keys()}
diff --git
a/providers/amazon/tests/unit/amazon/aws/executors/ecs/test_ecs_executor.py
b/providers/amazon/tests/unit/amazon/aws/executors/ecs/test_ecs_executor.py
index 8f5fe85bf10..b6159e258bc 100644
--- a/providers/amazon/tests/unit/amazon/aws/executors/ecs/test_ecs_executor.py
+++ b/providers/amazon/tests/unit/amazon/aws/executors/ecs/test_ecs_executor.py
@@ -1096,10 +1096,9 @@ class TestAwsEcsExecutor:
],
)
def test_executor_config_exceptions(self, bad_config, mock_executor,
mock_cmd):
- with pytest.raises(ValueError) as raised:
+ with pytest.raises(ValueError, match='Executor Config should never
override "name" or "command"'):
mock_executor.execute_async(mock_airflow_key, mock_cmd,
executor_config=bad_config)
- assert raised.match('Executor Config should never override "name" or
"command"')
assert len(mock_executor.pending_tasks) == 0
@mock.patch.object(ecs_executor_config, "build_task_kwargs")
@@ -1344,9 +1343,8 @@ class TestEcsExecutorConfig:
(CONFIG_GROUP_NAME, AllEcsConfigKeys.SECURITY_GROUPS): "sg1,sg2",
}
with conf_vars(conf_overrides):
- with pytest.raises(ValueError) as raised:
+ with pytest.raises(ValueError, match="At least one subnet is
required to run a task"):
ecs_executor_config.build_task_kwargs(conf)
- assert raised.match("At least one subnet is required to run a task.")
# TODO: When merged this needs updating to the actually supported version
@pytest.mark.skipif(
diff --git a/providers/standard/tests/unit/standard/operators/test_hitl.py
b/providers/standard/tests/unit/standard/operators/test_hitl.py
index cead25507bd..3a2197892eb 100644
--- a/providers/standard/tests/unit/standard/operators/test_hitl.py
+++ b/providers/standard/tests/unit/standard/operators/test_hitl.py
@@ -456,7 +456,7 @@ class TestApprovalOperator:
)
def test_init_with_multiple_set_to_true(self) -> None:
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="Passing multiple to
ApprovalOperator is not allowed."):
ApprovalOperator(
task_id="hitl_test",
subject="This is subject",