Skip to content

Commit

Permalink
fix line separator behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
BWMac committed Sep 20, 2024
1 parent 2d3b76c commit 86db1b5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/unit/synapseclient/unit_test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def test_csv_to_pandas_df_no_kwargs():
{"col1": [1, 2, 3], "col2": ["a", "b", "c"], "col3": [True, False, True]}
)

with patch.object(pd, "read_csv", return_value=expected_df) as mock_read_csv:
with patch.object(
pd, "read_csv", return_value=expected_df
) as mock_read_csv, patch.object(os, "linesep", "\r\n"):
# WHEN I call _csv_to_pandas_df with default parameters
df = _csv_to_pandas_df(
filepath="dummy_path.csv",
Expand All @@ -283,7 +285,7 @@ def test_csv_to_pandas_df_no_kwargs():
escapechar=synapseclient.table.DEFAULT_ESCAPSE_CHAR,
header=0,
skiprows=0,
lineterminator="\n",
lineterminator=None,
)

# AND I expect the returned DataFrame to be the same as the original DataFrame (file)
Expand All @@ -294,7 +296,9 @@ def test_csv_to_pandas_df_with_kwargs() -> None:
# GIVEN a pandas DataFrame (CSV file stand-in)
expected_df = pd.DataFrame({"col1": [1, 2, 3], "col2": ["a", "b", "c"]})

with patch.object(pd, "read_csv", return_value=expected_df) as mock_read_csv:
with patch.object(
pd, "read_csv", return_value=expected_df
) as mock_read_csv, patch.object(os, "linesep", "\r\n"):
# WHEN I call _csv_to_pandas_df with custom keyword arguments
kwargs = {"escapechar": "\\", "keep_default_na": False}
df = _csv_to_pandas_df(
Expand All @@ -321,7 +325,7 @@ def test_csv_to_pandas_df_with_kwargs() -> None:
header=0,
skiprows=0,
keep_default_na=False,
lineterminator="\n",
lineterminator=None,
)

# AND I expect the returned DataFrame to match the expected DataFrame
Expand Down

0 comments on commit 86db1b5

Please sign in to comment.