Skip to content

Commit 5249d09

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 58f1eb9 + a137e07 commit 5249d09

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

testing/test_awswrangler/test_moto.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest.mock import ANY
2+
13
import boto3
24
import botocore
35
import mock
@@ -219,6 +221,21 @@ def test_csv(s3):
219221
assert len(df.columns) == 10
220222

221223

224+
@mock.patch("pandas.read_csv")
225+
@mock.patch("s3fs.S3FileSystem.open")
226+
def test_read_csv_pass_pandas_arguments_and_encoding_succeed(mock_open, mock_read_csv, s3):
227+
bucket = "bucket"
228+
key = "foo/foo.csv"
229+
path = "s3://{}/{}".format(bucket, key)
230+
s3_object = s3.Object(bucket, key)
231+
s3_object.put(Body=b"foo")
232+
233+
with pytest.raises(TypeError):
234+
wr.s3.read_csv(path=path, encoding="ISO-8859-1", sep=",", lineterminator="\r\n")
235+
mock_open.assert_called_with(path="s3://bucket/foo/foo.csv", mode="r", encoding="ISO-8859-1", newline="\r\n")
236+
mock_read_csv.assert_called_with(ANY, compression=None, encoding="ISO-8859-1", sep=",", lineterminator="\r\n")
237+
238+
222239
def test_to_csv_invalid_argument_combination_raise_when_dataset_false_succeed(s3):
223240
path = "s3://bucket/test.csv"
224241
with pytest.raises(InvalidArgumentCombination):

0 commit comments

Comments
 (0)