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

potiuk 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 1fa80d38a45 Enable PT011 rule to prvoider tests (#56608)
1fa80d38a45 is described below

commit 1fa80d38a45ae01c53715aa13c560f6155ecc60a
Author: Xch1 <[email protected]>
AuthorDate: Tue Oct 14 21:16:09 2025 +0800

    Enable PT011 rule to prvoider tests (#56608)
    
    * modify test_named_hive_partition
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_openlineage
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_s3
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_redshift_to_s3
    
    Signed-off-by: Xch1 <[email protected]>
    
    * modify test_helpers
    
    Signed-off-by: Xch1 <[email protected]>
    
    ---------
    
    Signed-off-by: Xch1 <[email protected]>
---
 .../amazon/tests/unit/amazon/aws/system/utils/test_helpers.py     | 8 ++------
 .../amazon/tests/unit/amazon/aws/transfers/test_redshift_to_s3.py | 4 +++-
 providers/amazon/tests/unit/amazon/aws/triggers/test_s3.py        | 2 +-
 providers/amazon/tests/unit/amazon/aws/utils/test_openlineage.py  | 4 +++-
 .../tests/unit/apache/hive/sensors/test_named_hive_partition.py   | 2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git 
a/providers/amazon/tests/unit/amazon/aws/system/utils/test_helpers.py 
b/providers/amazon/tests/unit/amazon/aws/system/utils/test_helpers.py
index 82be197dc46..a1747610bfd 100644
--- a/providers/amazon/tests/unit/amazon/aws/system/utils/test_helpers.py
+++ b/providers/amazon/tests/unit/amazon/aws/system/utils/test_helpers.py
@@ -92,11 +92,9 @@ class TestAmazonSystemTestHelpers:
 
     def test_fetch_variable_no_value_found_raises_exception(self):
         # This would be the (None, None, None) test case from above.
-        with pytest.raises(ValueError) as raised_exception:
+        with pytest.raises(ValueError, match=NO_VALUE_MSG.format(key=ANY_STR)):
             utils.fetch_variable(key=ANY_STR, test_name=TEST_NAME)
 
-        assert NO_VALUE_MSG.format(key=ANY_STR) in str(raised_exception.value)
-
     ENV_ID_TEST_CASES = [
         # Happy Cases
         ("ABCD", True),
@@ -129,11 +127,9 @@ class TestAmazonSystemTestHelpers:
             if not result == env_id:
                 assert LOWERCASE_ENV_ID_MSG in captured_output.getvalue()
         else:
-            with pytest.raises(ValueError) as raised_exception:
+            with pytest.raises(ValueError, match=INVALID_ENV_ID_MSG):
                 _validate_env_id(env_id)
 
-            assert INVALID_ENV_ID_MSG in str(raised_exception.value)
-
     def test_set_env_id_generates_if_required(self):
         # No environment variable nor SSM value has been found
         result = set_env_id(TEST_NAME)
diff --git 
a/providers/amazon/tests/unit/amazon/aws/transfers/test_redshift_to_s3.py 
b/providers/amazon/tests/unit/amazon/aws/transfers/test_redshift_to_s3.py
index a5d26d05e63..67e4a67653d 100644
--- a/providers/amazon/tests/unit/amazon/aws/transfers/test_redshift_to_s3.py
+++ b/providers/amazon/tests/unit/amazon/aws/transfers/test_redshift_to_s3.py
@@ -428,7 +428,9 @@ class TestRedshiftToS3Transfer:
             dag=None,
         )
 
-        with pytest.raises(ValueError):
+        with pytest.raises(
+            ValueError, match="Please specify either a table or `select_query` 
to fetch the data."
+        ):
             op.execute(None)
 
     @pytest.mark.parametrize("table_as_file_name, expected_s3_key", [[True, 
"key/table_"], [False, "key"]])
diff --git a/providers/amazon/tests/unit/amazon/aws/triggers/test_s3.py 
b/providers/amazon/tests/unit/amazon/aws/triggers/test_s3.py
index 5043e2bb377..f55a6a0f157 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_s3.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_s3.py
@@ -131,7 +131,7 @@ class TestS3KeysUnchangedTrigger:
         """
         Test if the S3KeysUnchangedTrigger raises Value error for negative 
inactivity_period.
         """
-        with pytest.raises(ValueError):
+        with pytest.raises(ValueError, match="inactivity_period must be 
non-negative"):
             S3KeysUnchangedTrigger(bucket_name="test_bucket", prefix="test", 
inactivity_period=-100)
 
     @pytest.mark.asyncio
diff --git a/providers/amazon/tests/unit/amazon/aws/utils/test_openlineage.py 
b/providers/amazon/tests/unit/amazon/aws/utils/test_openlineage.py
index 195db068d30..3790a590238 100644
--- a/providers/amazon/tests/unit/amazon/aws/utils/test_openlineage.py
+++ b/providers/amazon/tests/unit/amazon/aws/utils/test_openlineage.py
@@ -164,5 +164,7 @@ def 
test_get_identity_column_lineage_facet_no_input_datasets():
     field_names = ["field1", "field2"]
     input_datasets = []
 
-    with pytest.raises(ValueError):
+    with pytest.raises(
+        ValueError, match="When providing `field_names` You must provide at 
least one `input_dataset`."
+    ):
         get_identity_column_lineage_facet(field_names=field_names, 
input_datasets=input_datasets)
diff --git 
a/providers/apache/hive/tests/unit/apache/hive/sensors/test_named_hive_partition.py
 
b/providers/apache/hive/tests/unit/apache/hive/sensors/test_named_hive_partition.py
index 2a1a66df04c..76f5552c0a6 100644
--- 
a/providers/apache/hive/tests/unit/apache/hive/sensors/test_named_hive_partition.py
+++ 
b/providers/apache/hive/tests/unit/apache/hive/sensors/test_named_hive_partition.py
@@ -72,7 +72,7 @@ class TestNamedHivePartitionSensor:
 
     def test_parse_partition_name_incorrect(self):
         name = "incorrect.name"
-        with pytest.raises(ValueError):
+        with pytest.raises(ValueError, match="Could not parse 
incorrect.nameinto table, partition"):
             NamedHivePartitionSensor.parse_partition_name(name)
 
     def test_parse_partition_name_default(self):

Reply via email to