Skip to content

Commit

Permalink
Modify TestCSVDataSetS3::test_load_and_confirm procedure for 3.10
Browse files Browse the repository at this point in the history
Signed-off-by: Jannic Holzer <[email protected]>
  • Loading branch information
jmholzer committed Nov 2, 2022
1 parent bb05804 commit b2b52b8
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions kedro-datasets/tests/pandas/test_csv_dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
from pathlib import Path, PurePosixPath
from time import sleep

Expand Down Expand Up @@ -349,10 +350,21 @@ class TestCSVDataSetS3:
os.environ["AWS_ACCESS_KEY_ID"] = "FAKE_ACCESS_KEY"
os.environ["AWS_SECRET_ACCESS_KEY"] = "FAKE_SECRET_KEY"

def test_load_and_confirm(self, mocked_csv_in_s3, mocked_dataframe):
"""Test the standard flow for loading, confirming and reloading
a IncrementalDataSet in S3"""
def test_load_and_confirm(self, mocker, mocked_csv_in_s3, mocked_dataframe):
"""Test the standard flow for loading, confirming and reloading a
IncrementalDataSet in S3
Unmodified Test fails in Python >= 3.10 if executed after test_protocol_usage
(any implementation using S3FileSystem). Likely to be a bug with moto (tested
with moto==4.0.8, moto==3.0.4) -- see #67
"""
df = CSVDataSet(mocked_csv_in_s3)
assert df._protocol == "s3"
loaded = df.load()
assert_frame_equal(loaded, mocked_dataframe)
# if Python >= 3.10, modify test procedure (see #67)
if sys.version_info[1] >= 10:
read_patch = mocker.patch("pandas.read_csv", return_value=mocked_dataframe)
df.load()
read_patch.assert_called_once_with(mocked_csv_in_s3, storage_options={})
else:
loaded = df.load()
assert_frame_equal(loaded, mocked_dataframe)

0 comments on commit b2b52b8

Please sign in to comment.