Skip to content

Commit 1308c9b

Browse files
committed
update s3 test
1 parent 9a676bc commit 1308c9b

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

pandas/tests/io/test_s3.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,29 @@
55
from pandas import read_csv
66

77

8-
def test_streaming_s3_objects():
9-
# GH17135
8+
@pytest.mark.parametrize("data", [b"foo,bar,baz\n1,2,3\n4,5,6\n", b"just,the,header\n"])
9+
def test_streaming_s3_objects(data):
10+
# GH 17135
1011
# botocore gained iteration support in 1.10.47, can now be used in read_*
1112
pytest.importorskip("botocore", minversion="1.10.47")
1213
from botocore.response import StreamingBody
1314

14-
data = [b"foo,bar,baz\n1,2,3\n4,5,6\n", b"just,the,header\n"]
15-
for el in data:
16-
body = StreamingBody(BytesIO(el), content_length=len(el))
17-
read_csv(body)
15+
body = StreamingBody(BytesIO(data), content_length=len(data))
16+
read_csv(body)
1817

1918

2019
@pytest.mark.single_cpu
21-
def test_read_without_creds_from_pub_bucket(s3_bucket_public_with_data, s3so):
22-
# GH 34626
23-
pytest.importorskip("s3fs")
24-
result = read_csv(
25-
f"s3://{s3_bucket_public_with_data.name}/tips.csv",
26-
nrows=3,
27-
storage_options=s3so,
28-
)
29-
assert len(result) == 3
30-
31-
32-
@pytest.mark.single_cpu
33-
def test_read_with_creds_from_pub_bucket(s3_bucket_public_with_data, s3so):
34-
# Ensure we can read from a public bucket with credentials
20+
@pytest.mark.parametrize("header", ["infer", None])
21+
def test_read_with_and_without_creds_from_pub_bucket(
22+
s3_bucket_public_with_data, s3so, header
23+
):
3524
# GH 34626
3625
pytest.importorskip("s3fs")
26+
nrows = 5
3727
df = read_csv(
3828
f"s3://{s3_bucket_public_with_data.name}/tips.csv",
39-
nrows=5,
40-
header=None,
29+
nrows=nrows,
30+
header=header,
4131
storage_options=s3so,
4232
)
43-
assert len(df) == 5
33+
assert len(df) == nrows

0 commit comments

Comments
 (0)