Skip to content

Commit

Permalink
Merge pull request pandas-dev#2 from dimastbk/issue-50395-dima-skip-t…
Browse files Browse the repository at this point in the history
…ests

calamine excel engine: skip tests with datetime
  • Loading branch information
kostyafarber authored Jan 22, 2023
2 parents 2dc5e02 + 0784733 commit 2076e11
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ def test_usecols_int(self, read_ext):
usecols=3,
)

def test_usecols_list(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_usecols_list(self, request, engine, read_ext, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand All @@ -191,11 +191,11 @@ def test_usecols_list(self, request, read_ext, df_ref):
tm.assert_frame_equal(df1, df_ref, check_names=False)
tm.assert_frame_equal(df2, df_ref, check_names=False)

def test_usecols_str(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_usecols_str(self, request, engine, read_ext, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -248,12 +248,12 @@ def test_usecols_str(self, request, read_ext, df_ref):
"usecols", [[0, 1, 3], [0, 3, 1], [1, 0, 3], [1, 3, 0], [3, 0, 1], [3, 1, 0]]
)
def test_usecols_diff_positional_int_columns_order(
self, request, read_ext, usecols, df_ref
self, request, engine, read_ext, usecols, df_ref
):
if read_ext == ".xlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand All @@ -271,23 +271,23 @@ def test_usecols_diff_positional_str_columns_order(self, read_ext, usecols, df_r
result = pd.read_excel("test1" + read_ext, sheet_name="Sheet1", usecols=usecols)
tm.assert_frame_equal(result, expected, check_names=False)

def test_read_excel_without_slicing(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_read_excel_without_slicing(self, request, engine, read_ext, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

expected = df_ref
result = pd.read_excel("test1" + read_ext, sheet_name="Sheet1", index_col=0)
tm.assert_frame_equal(result, expected, check_names=False)

def test_usecols_excel_range_str(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_usecols_excel_range_str(self, request, engine, read_ext, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -363,23 +363,23 @@ def test_excel_stop_iterator(self, read_ext):
expected = DataFrame([["aaaa", "bbbbb"]], columns=["Test", "Test1"])
tm.assert_frame_equal(parsed, expected)

def test_excel_cell_error_na(self, request, read_ext):
if read_ext == ".xlsb":
def test_excel_cell_error_na(self, request, engine, read_ext):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

parsed = pd.read_excel("test3" + read_ext, sheet_name="Sheet1")
expected = DataFrame([[np.nan]], columns=["Test"])
tm.assert_frame_equal(parsed, expected)

def test_excel_table(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_excel_table(self, request, engine, read_ext, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand All @@ -396,11 +396,11 @@ def test_excel_table(self, request, read_ext, df_ref):
)
tm.assert_frame_equal(df3, df1.iloc[:-1])

def test_reader_special_dtypes(self, request, read_ext):
if read_ext == ".xlsb":
def test_reader_special_dtypes(self, request, engine, read_ext):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -740,10 +740,10 @@ def test_exception_message_includes_sheet_name(self, read_ext):
@pytest.mark.filterwarnings("ignore:Cell A4 is marked:UserWarning:openpyxl")
def test_date_conversion_overflow(self, request, engine, read_ext):
# GH 10001 : pandas.ExcelFile ignore parse_dates=False
if engine == "pyxlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand All @@ -770,11 +770,11 @@ def test_date_conversion_overflow(self, request, engine, read_ext):
result = pd.read_excel("testdateoverflow" + read_ext)
tm.assert_frame_equal(result, expected)

def test_sheet_name(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_sheet_name(self, request, read_ext, engine, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)
filename = "test1"
Expand Down Expand Up @@ -945,10 +945,10 @@ def test_close_from_py_localpath(self, read_ext):
f.read()

def test_reader_seconds(self, request, engine, read_ext):
if engine == "pyxlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -977,12 +977,12 @@ def test_reader_seconds(self, request, engine, read_ext):
actual = pd.read_excel("times_1904" + read_ext, sheet_name="Sheet1")
tm.assert_frame_equal(actual, expected)

def test_read_excel_multiindex(self, request, read_ext):
def test_read_excel_multiindex(self, request, engine, read_ext):
# see gh-4679
if read_ext == ".xlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -1071,13 +1071,13 @@ def test_read_excel_multiindex(self, request, read_ext):
],
)
def test_read_excel_multiindex_blank_after_name(
self, request, read_ext, sheet_name, idx_lvl2
self, request, engine, read_ext, sheet_name, idx_lvl2
):
# GH34673
if read_ext == ".xlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb (GH4679"
reason=f"Sheets containing datetimes not supported by {engine} (GH4679)"
)
)

Expand Down Expand Up @@ -1194,12 +1194,12 @@ def test_read_excel_bool_header_arg(self, read_ext):
with pytest.raises(TypeError, match=msg):
pd.read_excel("test1" + read_ext, header=arg)

def test_read_excel_skiprows(self, request, read_ext):
def test_read_excel_skiprows(self, request, engine, read_ext):
# GH 4903
if read_ext == ".xlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -1249,12 +1249,12 @@ def test_read_excel_skiprows(self, request, read_ext):
)
tm.assert_frame_equal(actual, expected)

def test_read_excel_skiprows_callable_not_in(self, request, read_ext):
def test_read_excel_skiprows_callable_not_in(self, request, engine, read_ext):
# GH 4903
if read_ext == ".xlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -1381,10 +1381,10 @@ def test_ignore_chartsheets_by_str(self, request, engine, read_ext):
# GH 41448
if read_ext == ".ods":
pytest.skip("chartsheets do not exist in the ODF format")
if engine == "pyxlsb":
if engine in {"pyxlsb", "calamine"}:
request.node.add_marker(
pytest.mark.xfail(
reason="pyxlsb can't distinguish chartsheets from worksheets"
reason=f"{engine} can't distinguish chartsheets from worksheets"
)
)
with pytest.raises(ValueError, match="Worksheet named 'Chart1' not found"):
Expand All @@ -1394,10 +1394,10 @@ def test_ignore_chartsheets_by_int(self, request, engine, read_ext):
# GH 41448
if read_ext == ".ods":
pytest.skip("chartsheets do not exist in the ODF format")
if engine == "pyxlsb":
if engine in {"pyxlsb", "calamine"}:
request.node.add_marker(
pytest.mark.xfail(
reason="pyxlsb can't distinguish chartsheets from worksheets"
reason=f"{engine} can't distinguish chartsheets from worksheets"
)
)
with pytest.raises(
Expand Down Expand Up @@ -1510,11 +1510,11 @@ def test_excel_passes_na_filter(self, read_ext, na_filter):
expected = DataFrame(expected, columns=["Test"])
tm.assert_frame_equal(parsed, expected)

def test_excel_table_sheet_by_index(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_excel_table_sheet_by_index(self, request, engine, read_ext, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand All @@ -1539,11 +1539,11 @@ def test_excel_table_sheet_by_index(self, request, read_ext, df_ref):

tm.assert_frame_equal(df3, df1.iloc[:-1])

def test_sheet_name(self, request, read_ext, df_ref):
if read_ext == ".xlsb":
def test_sheet_name(self, request, engine, read_ext, df_ref):
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -1632,10 +1632,10 @@ def test_header_with_index_col(self, filename):

def test_read_datetime_multiindex(self, request, engine, read_ext):
# GH 34748
if engine == "pyxlsb":
if engine in {"calamine", "pyxlsb"}:
request.node.add_marker(
pytest.mark.xfail(
reason="Sheets containing datetimes not supported by pyxlsb"
reason=f"Sheets containing datetimes not supported by {engine}"
)
)

Expand Down Expand Up @@ -1663,10 +1663,10 @@ def test_ignore_chartsheets(self, request, engine, read_ext):
# GH 41448
if read_ext == ".ods":
pytest.skip("chartsheets do not exist in the ODF format")
if engine == "pyxlsb":
if engine in {"pyxlsb", "calamine"}:
request.node.add_marker(
pytest.mark.xfail(
reason="pyxlsb can't distinguish chartsheets from worksheets"
reason=f"{engine} can't distinguish chartsheets from worksheets"
)
)
with pd.ExcelFile("chartsheet" + read_ext) as excel:
Expand Down

0 comments on commit 2076e11

Please sign in to comment.