From 9f746a7ac2fe5fe4747e6cab9b3c386c2287bb36 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 13:43:07 +0100 Subject: [PATCH] CI: Fix botocore Error (#34087) * Update Error Msg * Fix botocore error * Add match pattern * black * Add AWS Docs & Fix Parquet Test * Docs * Docs --- pandas/tests/io/parser/test_network.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index 000fc605dd5b1..e0dee878006b8 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -172,17 +172,28 @@ def test_read_s3_fails(self): def test_write_s3_csv_fails(self, tips_df): # GH 32486 # Attempting to write to an invalid S3 path should raise - with pytest.raises( - FileNotFoundError, match="The specified bucket does not exist" - ): + import botocore + + # GH 34087 + # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html + # Catch a ClientError since AWS Service Errors are defined dynamically + error = (FileNotFoundError, botocore.exceptions.ClientError) + + with pytest.raises(error, match="The specified bucket does not exist"): tips_df.to_csv("s3://an_s3_bucket_data_doesnt_exit/not_real.csv") @td.skip_if_no("pyarrow") def test_write_s3_parquet_fails(self, tips_df): # GH 27679 - with pytest.raises( - FileNotFoundError, match="The specified bucket does not exist" - ): + # Attempting to write to an invalid S3 path should raise + import botocore + + # GH 34087 + # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html + # Catch a ClientError since AWS Service Errors are defined dynamically + error = (FileNotFoundError, botocore.exceptions.ClientError) + + with pytest.raises(error, match="The specified bucket does not exist"): tips_df.to_parquet("s3://an_s3_bucket_data_doesnt_exit/not_real.parquet") def test_read_csv_handles_boto_s3_object(self, s3_resource, tips_file):