Taragolis commented on code in PR #28139:
URL: https://github.com/apache/airflow/pull/28139#discussion_r1040571178
##########
tests/providers/amazon/aws/sensors/test_batch.py:
##########
@@ -44,25 +43,25 @@ def setUp(self):
@mock.patch.object(BatchClientHook, "get_job_description")
def test_poke_on_success_state(self, mock_get_job_description):
mock_get_job_description.return_value = {"status": "SUCCEEDED"}
- self.assertTrue(self.batch_sensor.poke({}))
+ assert self.batch_sensor.poke({})
mock_get_job_description.assert_called_once_with(JOB_ID)
@mock.patch.object(BatchClientHook, "get_job_description")
def test_poke_on_failure_state(self, mock_get_job_description):
mock_get_job_description.return_value = {"status": "FAILED"}
- with self.assertRaises(AirflowException) as e:
+ with pytest.raises(AirflowException) as ctx:
self.batch_sensor.poke({})
- self.assertEqual("Batch sensor failed. AWS Batch job status: FAILED",
str(e.exception))
+ assert "Batch sensor failed. AWS Batch job status: FAILED" ==
str(ctx.value)
Review Comment:
You could use `match` argument in `pytest.raises` for check exception error
message, [some
sample](https://github.com/Taragolis/airflow/blob/6ecb2f8cc4a949284e3143796ee5c4097bde1c25/tests/providers/amazon/aws/sensors/test_batch.py#L51-L54)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]