This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch v2-0-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit ad50ff27d7b2aef7c406620706675c6e1b494bcb Author: Ash Berlin-Taylor <[email protected]> AuthorDate: Mon Feb 22 20:17:31 2021 +0000 Remove testfixtures module that is only used once (#14318) This is only used in a single test, everywhere else we use Pytest or unittest's built in feature (cherry picked from commit 3a046faaeb457572b1484faf158cc96eb81df44a) --- setup.py | 1 - tests/providers/amazon/aws/hooks/test_glacier.py | 65 ++++++++++-------------- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/setup.py b/setup.py index 92eb113..ad4fdd5 100644 --- a/setup.py +++ b/setup.py @@ -508,7 +508,6 @@ devel = [ 'pywinrm', 'qds-sdk>=1.9.6', 'requests_mock', - 'testfixtures', 'wheel', 'yamllint', ] diff --git a/tests/providers/amazon/aws/hooks/test_glacier.py b/tests/providers/amazon/aws/hooks/test_glacier.py index c1c86a5..c22620f 100644 --- a/tests/providers/amazon/aws/hooks/test_glacier.py +++ b/tests/providers/amazon/aws/hooks/test_glacier.py @@ -19,8 +19,6 @@ import unittest from unittest import mock -from testfixtures import LogCapture - from airflow.providers.amazon.aws.hooks.glacier import GlacierHook CREDENTIALS = "aws_conn" @@ -52,26 +50,20 @@ class TestAmazonGlacierHook(unittest.TestCase): # given job_id = {"jobId": "1234abcd"} # when - with LogCapture() as log: + with self.assertLogs() as log: mock_conn.return_value.initiate_job.return_value = job_id self.hook.retrieve_inventory(VAULT_NAME) # then - log.check( - ( - 'airflow.providers.amazon.aws.hooks.glacier.GlacierHook', - 'INFO', - f"Retrieving inventory for vault: {VAULT_NAME}", - ), - ( - 'airflow.providers.amazon.aws.hooks.glacier.GlacierHook', - 'INFO', - f"Initiated inventory-retrieval job for: {VAULT_NAME}", - ), - ( - 'airflow.providers.amazon.aws.hooks.glacier.GlacierHook', - 'INFO', - f"Retrieval Job ID: {job_id.get('jobId')}", - ), + self.assertEqual( + log.output, + [ + 'INFO:airflow.providers.amazon.aws.hooks.glacier.GlacierHook:' + + f"Retrieving inventory for vault: {VAULT_NAME}", + 'INFO:airflow.providers.amazon.aws.hooks.glacier.GlacierHook:' + + f"Initiated inventory-retrieval job for: {VAULT_NAME}", + 'INFO:airflow.providers.amazon.aws.hooks.glacier.GlacierHook:' + + f"Retrieval Job ID: {job_id.get('jobId')}", + ], ) @mock.patch("airflow.providers.amazon.aws.hooks.glacier.GlacierHook.get_conn") @@ -86,16 +78,16 @@ class TestAmazonGlacierHook(unittest.TestCase): @mock.patch("airflow.providers.amazon.aws.hooks.glacier.GlacierHook.get_conn") def test_retrieve_inventory_results_should_log_mgs(self, mock_conn): # when - with LogCapture() as log: + with self.assertLogs() as log: mock_conn.return_value.get_job_output.return_value = REQUEST_RESULT self.hook.retrieve_inventory_results(VAULT_NAME, JOB_ID) # then - log.check( - ( - 'airflow.providers.amazon.aws.hooks.glacier.GlacierHook', - 'INFO', - f"Retrieving the job results for vault: {VAULT_NAME}...", - ), + self.assertEqual( + log.output, + [ + 'INFO:airflow.providers.amazon.aws.hooks.glacier.GlacierHook:' + + f"Retrieving the job results for vault: {VAULT_NAME}...", + ], ) @mock.patch("airflow.providers.amazon.aws.hooks.glacier.GlacierHook.get_conn") @@ -110,19 +102,16 @@ class TestAmazonGlacierHook(unittest.TestCase): @mock.patch("airflow.providers.amazon.aws.hooks.glacier.GlacierHook.get_conn") def test_describe_job_should_log_mgs(self, mock_conn): # when - with LogCapture() as log: + with self.assertLogs() as log: mock_conn.return_value.describe_job.return_value = JOB_STATUS self.hook.describe_job(VAULT_NAME, JOB_ID) # then - log.check( - ( - 'airflow.providers.amazon.aws.hooks.glacier.GlacierHook', - 'INFO', - f"Retrieving status for vault: {VAULT_NAME} and job {JOB_ID}", - ), - ( - 'airflow.providers.amazon.aws.hooks.glacier.GlacierHook', - 'INFO', - f"Job status: {JOB_STATUS.get('Action')}, code status: {JOB_STATUS.get('StatusCode')}", - ), + self.assertEqual( + log.output, + [ + 'INFO:airflow.providers.amazon.aws.hooks.glacier.GlacierHook:' + + f"Retrieving status for vault: {VAULT_NAME} and job {JOB_ID}", + 'INFO:airflow.providers.amazon.aws.hooks.glacier.GlacierHook:' + + f"Job status: {JOB_STATUS.get('Action')}, code status: {JOB_STATUS.get('StatusCode')}", + ], )
