|
5 | 5 | from pandas import read_csv
|
6 | 6 |
|
7 | 7 |
|
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 |
10 | 11 | # botocore gained iteration support in 1.10.47, can now be used in read_*
|
11 | 12 | pytest.importorskip("botocore", minversion="1.10.47")
|
12 | 13 | from botocore.response import StreamingBody
|
13 | 14 |
|
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) |
18 | 17 |
|
19 | 18 |
|
20 | 19 | @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 | +): |
35 | 24 | # GH 34626
|
36 | 25 | pytest.importorskip("s3fs")
|
| 26 | + nrows = 5 |
37 | 27 | df = read_csv(
|
38 | 28 | f"s3://{s3_bucket_public_with_data.name}/tips.csv",
|
39 |
| - nrows=5, |
40 |
| - header=None, |
| 29 | + nrows=nrows, |
| 30 | + header=header, |
41 | 31 | storage_options=s3so,
|
42 | 32 | )
|
43 |
| - assert len(df) == 5 |
| 33 | + assert len(df) == nrows |
0 commit comments