From a38e8829789ed8b2ce94130012872bea6ef7ad75 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 02:08:40 +0100 Subject: [PATCH 1/7] Update Error Msg --- pandas/tests/io/parser/test_network.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index 000fc605dd5b1..5973979e90a8f 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -169,11 +169,14 @@ def test_read_s3_fails(self): with pytest.raises(IOError): read_csv("s3://cant_get_it/file.csv") + @td.skip_if_no("botocore") def test_write_s3_csv_fails(self, tips_df): # GH 32486 # Attempting to write to an invalid S3 path should raise + import botocore + with pytest.raises( - FileNotFoundError, match="The specified bucket does not exist" + botocore.errorfactory.NoSuchBucket, match="An error occurred (NoSuchBucket)" ): tips_df.to_csv("s3://an_s3_bucket_data_doesnt_exit/not_real.csv") From 730256d5e7f84adeb7ff374bed52ec031b381f30 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 03:58:55 +0100 Subject: [PATCH 2/7] Fix botocore error --- pandas/tests/io/parser/test_network.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index 5973979e90a8f..e949f9fd42d02 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -173,11 +173,10 @@ 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 + # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html import botocore - with pytest.raises( - botocore.errorfactory.NoSuchBucket, match="An error occurred (NoSuchBucket)" - ): + with pytest.raises(botocore.exceptions.ClientError): tips_df.to_csv("s3://an_s3_bucket_data_doesnt_exit/not_real.csv") @td.skip_if_no("pyarrow") From ae6139ced3b165f382ccc8db94baacdacc01cff2 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 04:03:11 +0100 Subject: [PATCH 3/7] Add match pattern --- pandas/tests/io/parser/test_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index e949f9fd42d02..2f52eaff60225 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -176,7 +176,7 @@ def test_write_s3_csv_fails(self, tips_df): # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html import botocore - with pytest.raises(botocore.exceptions.ClientError): + with pytest.raises(botocore.exceptions.ClientError, 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") From 0d78961d65864d00537cef3727b5c74d9b12e422 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 04:06:52 +0100 Subject: [PATCH 4/7] black --- pandas/tests/io/parser/test_network.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index 2f52eaff60225..aee550e07ca4e 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -176,7 +176,9 @@ def test_write_s3_csv_fails(self, tips_df): # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html import botocore - with pytest.raises(botocore.exceptions.ClientError, match="The specified bucket does not exist"): + with pytest.raises( + botocore.exceptions.ClientError, 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") From d43bb032882f801f6168c89d862f2b6535c968ff Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 11:52:33 +0100 Subject: [PATCH 5/7] Add AWS Docs & Fix Parquet Test --- pandas/tests/io/parser/test_network.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index aee550e07ca4e..ec409006cb498 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -169,24 +169,31 @@ def test_read_s3_fails(self): with pytest.raises(IOError): read_csv("s3://cant_get_it/file.csv") - @td.skip_if_no("botocore") def test_write_s3_csv_fails(self, tips_df): # GH 32486 # Attempting to write to an invalid S3 path should raise # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html + # Catch a ClientError since AWS Service Errors are defined dynamically import botocore - with pytest.raises( - botocore.exceptions.ClientError, match="The specified bucket does not exist" - ): + # GH 34087 + 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" - ): + # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html + 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): From f3be192a7d279554d15eb18007980aff2b846adc Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 11:56:08 +0100 Subject: [PATCH 6/7] Docs --- pandas/tests/io/parser/test_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index ec409006cb498..e83094536bc08 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -172,11 +172,11 @@ 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 - # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html - # Catch a ClientError since AWS Service Errors are defined dynamically 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"): From de6e45dcc05b6bbbe272da94d55d65a0c39c850d Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 9 May 2020 12:01:15 +0100 Subject: [PATCH 7/7] Docs --- pandas/tests/io/parser/test_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/parser/test_network.py b/pandas/tests/io/parser/test_network.py index e83094536bc08..e0dee878006b8 100644 --- a/pandas/tests/io/parser/test_network.py +++ b/pandas/tests/io/parser/test_network.py @@ -185,7 +185,7 @@ def test_write_s3_csv_fails(self, tips_df): @td.skip_if_no("pyarrow") def test_write_s3_parquet_fails(self, tips_df): # GH 27679 - # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html + # Attempting to write to an invalid S3 path should raise import botocore # GH 34087