Skip to content

Commit eba6c5f

Browse files
committed
Public Bucket Read Test
1 parent 49888e0 commit eba6c5f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pandas/io/s3.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def _strip_schema(url):
1616
return result.netloc + result.path
1717

1818

19-
def get_fs():
20-
return s3fs.S3FileSystem(anon=False)
19+
def get_fs(anon: bool = False):
20+
return s3fs.S3FileSystem(anon=anon)
2121

2222

2323
def get_file_and_filesystem(
@@ -38,7 +38,7 @@ def get_file_and_filesystem(
3838
# aren't valid for that bucket.
3939
# A NoCredentialsError is raised if you don't have creds
4040
# for that bucket.
41-
fs = get_fs()
41+
fs = get_fs(anon=True)
4242
file = fs.open(_strip_schema(filepath_or_buffer), mode)
4343
return file, fs
4444

pandas/tests/io/test_s3.py

+10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import pytest
44

5+
import pandas.util._test_decorators as td
6+
57
from pandas import read_csv
8+
import pandas._testing as tm
69

710
from pandas.io.common import is_s3_url
811

@@ -23,3 +26,10 @@ def test_streaming_s3_objects():
2326
for el in data:
2427
body = StreamingBody(BytesIO(el), content_length=len(el))
2528
read_csv(body)
29+
30+
31+
@tm.network
32+
@td.skip_if_no("s3fs")
33+
def test_read_without_creds_from_pub_bucket():
34+
result = read_csv("s3://gdelt-open-data/events/1981.csv", nrows=3)
35+
assert len(result) == 3

0 commit comments

Comments
 (0)