Skip to content

Commit 9f746a7

Browse files
authored
CI: Fix botocore Error (#34087)
* Update Error Msg * Fix botocore error * Add match pattern * black * Add AWS Docs & Fix Parquet Test * Docs * Docs
1 parent 9ed015f commit 9f746a7

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pandas/tests/io/parser/test_network.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,28 @@ def test_read_s3_fails(self):
172172
def test_write_s3_csv_fails(self, tips_df):
173173
# GH 32486
174174
# Attempting to write to an invalid S3 path should raise
175-
with pytest.raises(
176-
FileNotFoundError, match="The specified bucket does not exist"
177-
):
175+
import botocore
176+
177+
# GH 34087
178+
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html
179+
# Catch a ClientError since AWS Service Errors are defined dynamically
180+
error = (FileNotFoundError, botocore.exceptions.ClientError)
181+
182+
with pytest.raises(error, match="The specified bucket does not exist"):
178183
tips_df.to_csv("s3://an_s3_bucket_data_doesnt_exit/not_real.csv")
179184

180185
@td.skip_if_no("pyarrow")
181186
def test_write_s3_parquet_fails(self, tips_df):
182187
# GH 27679
183-
with pytest.raises(
184-
FileNotFoundError, match="The specified bucket does not exist"
185-
):
188+
# Attempting to write to an invalid S3 path should raise
189+
import botocore
190+
191+
# GH 34087
192+
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html
193+
# Catch a ClientError since AWS Service Errors are defined dynamically
194+
error = (FileNotFoundError, botocore.exceptions.ClientError)
195+
196+
with pytest.raises(error, match="The specified bucket does not exist"):
186197
tips_df.to_parquet("s3://an_s3_bucket_data_doesnt_exit/not_real.parquet")
187198

188199
def test_read_csv_handles_boto_s3_object(self, s3_resource, tips_file):

0 commit comments

Comments
 (0)