From 0784733b2f4ebc72f9aeb09fac839ebec5d8ac59 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Thu, 12 Jan 2023 11:02:52 +0600 Subject: [PATCH] calamine excel engine: skip tests with datetime --- pandas/tests/io/excel/test_readers.py | 114 +++++++++++++------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/pandas/tests/io/excel/test_readers.py b/pandas/tests/io/excel/test_readers.py index 68a641c3c81eb..c17e6db26c26d 100644 --- a/pandas/tests/io/excel/test_readers.py +++ b/pandas/tests/io/excel/test_readers.py @@ -168,11 +168,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}" ) ) @@ -192,11 +192,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}" ) ) @@ -249,12 +249,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}" ) ) @@ -272,11 +272,11 @@ 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}" ) ) @@ -284,11 +284,11 @@ def test_read_excel_without_slicing(self, request, read_ext, 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}" ) ) @@ -364,11 +364,11 @@ 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}" ) ) @@ -376,11 +376,11 @@ def test_excel_cell_error_na(self, request, read_ext): 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}" ) ) @@ -397,11 +397,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}" ) ) @@ -741,10 +741,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}" ) ) @@ -771,11 +771,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" @@ -946,10 +946,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}" ) ) @@ -978,12 +978,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}" ) ) @@ -1072,13 +1072,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)" ) ) @@ -1195,12 +1195,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}" ) ) @@ -1250,12 +1250,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}" ) ) @@ -1382,10 +1382,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"): @@ -1395,10 +1395,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( @@ -1511,11 +1511,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}" ) ) @@ -1540,11 +1540,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}" ) ) @@ -1633,10 +1633,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}" ) ) @@ -1664,10 +1664,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: