Skip to content

Commit dd3d531

Browse files
authored
Enable PT011 rule to prvoider tests (apache#56929)
1 parent a6d3e2d commit dd3d531

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

devel-common/tests/unit/tests_common/test_utils/test_stream_capture_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def test_exception_during_capture_with_pytest_raises(stdout_capture):
463463
assert "Log before exception" not in output
464464

465465
# Now test that exception in capture context still works
466-
with pytest.raises(ValueError):
466+
with pytest.raises(ValueError, match="Test exception"):
467467
with stdout_capture:
468468
raise ValueError("Test exception")
469469

providers/amazon/tests/unit/amazon/aws/assets/test_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_sanitize_uri():
3838

3939

4040
def test_sanitize_uri_no_netloc():
41-
with pytest.raises(ValueError):
41+
with pytest.raises(ValueError, match="URI format s3:// must contain a bucket name"):
4242
sanitize_uri(urllib.parse.urlsplit("s3://"))
4343

4444

providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,9 @@ def test_validate_config_defaults(self):
744744
],
745745
)
746746
def test_executor_config_exceptions(self, bad_config, mock_executor):
747-
with pytest.raises(ValueError) as raised:
747+
with pytest.raises(ValueError, match='Executor Config should never override "command'):
748748
mock_executor.execute_async(mock_airflow_key, mock_cmd, executor_config=bad_config)
749749

750-
assert raised.match('Executor Config should never override "command')
751-
752750
def test_config_defaults_are_applied(self):
753751
submit_kwargs = batch_executor_config.build_submit_kwargs()
754752
found_keys = {convert_camel_to_snake(key): key for key in submit_kwargs.keys()}

providers/amazon/tests/unit/amazon/aws/executors/ecs/test_ecs_executor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,9 @@ def sync_mock():
10961096
],
10971097
)
10981098
def test_executor_config_exceptions(self, bad_config, mock_executor, mock_cmd):
1099-
with pytest.raises(ValueError) as raised:
1099+
with pytest.raises(ValueError, match='Executor Config should never override "name" or "command"'):
11001100
mock_executor.execute_async(mock_airflow_key, mock_cmd, executor_config=bad_config)
11011101

1102-
assert raised.match('Executor Config should never override "name" or "command"')
11031102
assert len(mock_executor.pending_tasks) == 0
11041103

11051104
@mock.patch.object(ecs_executor_config, "build_task_kwargs")
@@ -1344,9 +1343,8 @@ def test_subnets_required(self):
13441343
(CONFIG_GROUP_NAME, AllEcsConfigKeys.SECURITY_GROUPS): "sg1,sg2",
13451344
}
13461345
with conf_vars(conf_overrides):
1347-
with pytest.raises(ValueError) as raised:
1346+
with pytest.raises(ValueError, match="At least one subnet is required to run a task"):
13481347
ecs_executor_config.build_task_kwargs(conf)
1349-
assert raised.match("At least one subnet is required to run a task.")
13501348

13511349
# TODO: When merged this needs updating to the actually supported version
13521350
@pytest.mark.skipif(

providers/standard/tests/unit/standard/operators/test_hitl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def test_init_with_options(self) -> None:
456456
)
457457

458458
def test_init_with_multiple_set_to_true(self) -> None:
459-
with pytest.raises(ValueError):
459+
with pytest.raises(ValueError, match="Passing multiple to ApprovalOperator is not allowed."):
460460
ApprovalOperator(
461461
task_id="hitl_test",
462462
subject="This is subject",

0 commit comments

Comments
 (0)