Skip to content

Commit

Permalink
TEST-#2291: minor refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Myskov <alexander.myskov@intel.com>
  • Loading branch information
amyskov committed Dec 1, 2020
1 parent de909c3 commit d2d269f
Showing 1 changed file with 38 additions and 57 deletions.
95 changes: 38 additions & 57 deletions modin/pandas/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,6 @@ class TestReadCSV:
def test_read_csv_delimiters(
self, make_csv_file, sep, delimiter, decimal, thousands
):
kwargs = {
"delimiter": delimiter,
"sep": sep,
"decimal": decimal,
"thousands": thousands,
}
unique_filename = get_unique_filename()
make_csv_file(
filename=unique_filename,
Expand All @@ -575,9 +569,13 @@ def test_read_csv_delimiters(
)

eval_io(
filepath_or_buffer=unique_filename,
fn_name="read_csv",
**kwargs,
# read_csv kwargs
filepath_or_buffer=unique_filename,
delimiter=delimiter,
sep=sep,
decimal=decimal,
thousands=thousands,
)

# Column and Index Locations and Names tests
Expand Down Expand Up @@ -610,19 +608,16 @@ def test_read_csv_col_handling(
"The reason of tests fail in `cloud` mode is unknown for now - issue #2340"
)

kwargs = {
"header": header,
"index_col": index_col,
"prefix": prefix,
"names": names,
"usecols": usecols,
"skip_blank_lines": skip_blank_lines,
}

eval_io(
filepath_or_buffer=pytest.csvs_names["test_read_csv_blank_lines"],
fn_name="read_csv",
**kwargs,
# read_csv kwargs
filepath_or_buffer=pytest.csvs_names["test_read_csv_blank_lines"],
header=header,
index_col=index_col,
prefix=prefix,
names=names,
usecols=usecols,
skip_blank_lines=skip_blank_lines,
)

# General Parsing Configuration
Expand Down Expand Up @@ -652,28 +647,26 @@ def test_read_csv_parsing_1(
pytest.xfail(
"The reason of tests fail in `cloud` mode is unknown for now - issue #2340"
)
kwargs = {
"dtype": dtype,
"engine": engine,
"converters": converters,
"skipfooter": skipfooter,
}

if kwargs["dtype"]:
kwargs["dtype"] = {
if dtype:
dtype = {
col: "object"
for col in pandas.read_csv(
pytest.csvs_names["test_read_csv_regular"], nrows=1
).columns
}

eval_io(
filepath_or_buffer=pytest.csvs_names["test_read_csv_regular"],
fn_name="read_csv",
check_exception_type=None, # issue #2320
raising_exceptions=None,
check_kwargs_callable=not callable(converters),
**kwargs,
# read_csv kwargs
filepath_or_buffer=pytest.csvs_names["test_read_csv_regular"],
dtype=dtype,
engine=engine,
converters=converters,
skipfooter=skipfooter,
)

@pytest.mark.parametrize("true_values", [["Yes"], ["Yes", "true"], None])
Expand All @@ -698,22 +691,20 @@ def test_read_csv_parsing_2(
pytest.xfail(
"The reason of tests fail in `cloud` mode is unknown for now - issue #2340"
)
kwargs = {
"true_values": true_values,
"false_values": false_values,
"skiprows": skiprows,
"skipfooter": skipfooter,
"nrows": nrows,
"names": names,
}

eval_io(
filepath_or_buffer=pytest.csvs_names["test_read_csv_yes_no"],
fn_name="read_csv",
check_exception_type=None, # issue #2320
raising_exceptions=None,
check_kwargs_callable=not callable(skiprows),
**kwargs,
# read_csv kwargs
filepath_or_buffer=pytest.csvs_names["test_read_csv_yes_no"],
true_values=true_values,
false_values=false_values,
skiprows=skiprows,
skipfooter=skipfooter,
nrows=nrows,
names=names,
)

def test_read_csv_skipinitialspace(self, make_csv_file):
Expand Down Expand Up @@ -767,13 +758,6 @@ def test_read_csv_nans_handling(
verbose,
skip_blank_lines,
):
kwargs = {
"na_values": na_values,
"keep_default_na": keep_default_na,
"na_filter": na_filter,
"verbose": verbose,
"skip_blank_lines": skip_blank_lines,
}
eval_io(
filepath_or_buffer=pytest.csvs_names["test_read_csv_nans"],
fn_name="read_csv",
Expand Down Expand Up @@ -831,21 +815,18 @@ def test_read_csv_datetime(
raising_exceptions = list(io_ops_bad_exc)
raising_exceptions.remove(TypeError)

kwargs = {
"parse_dates": parse_dates,
"infer_datetime_format": infer_datetime_format,
"keep_date_col": keep_date_col,
"date_parser": date_parser,
"dayfirst": dayfirst,
"cache_dates": cache_dates,
}

eval_io(
filepath_or_buffer=pytest.csvs_names["test_read_csv_regular"],
fn_name="read_csv",
check_kwargs_callable=not callable(date_parser),
raising_exceptions=raising_exceptions,
**kwargs,
# read_csv kwargs
filepath_or_buffer=pytest.csvs_names["test_read_csv_regular"],
parse_dates=parse_dates,
infer_datetime_format=infer_datetime_format,
keep_date_col=keep_date_col,
date_parser=date_parser,
dayfirst=dayfirst,
cache_dates=cache_dates,
)


Expand Down

0 comments on commit d2d269f

Please sign in to comment.