Skip to content

Commit 1c11dba

Browse files
alimcmaster1simonjayhawkins
authored andcommitted
CI: Fix botocore Error (pandas-dev#34087)
* Update Error Msg * Fix botocore error * Add match pattern * black * Add AWS Docs & Fix Parquet Test * Docs * Docs
1 parent e39390e commit 1c11dba

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pandas/tests/io/parser/test_network.py

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

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

187198
def test_read_csv_handles_boto_s3_object(self, s3_resource, tips_file):

0 commit comments

Comments
 (0)