From 92d60ae8899a824c5daaed430d292a4685bb27e7 Mon Sep 17 00:00:00 2001 From: fspreck <f.spreckelsen@indiscale.com> Date: Wed, 26 May 2021 10:27:08 +0200 Subject: [PATCH] TST: Add unittest for .xls file --- unittests/test_table_importer.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/unittests/test_table_importer.py b/unittests/test_table_importer.py index 6681ed2c..46427c16 100644 --- a/unittests/test_table_importer.py +++ b/unittests/test_table_importer.py @@ -77,7 +77,8 @@ class ConverterTest(unittest.TestCase): # TODO datatypes are different; fix it assert df.d.iloc[0] == datetime.datetime(1980, 12, 31, 13, 24, 23) - def test_date(self): + def test_date_xlsx(self): + """Test with .xlsx in order to check openpyxl engine.""" test_file = os.path.join(os.path.dirname(__file__), "date.xlsx") self.importer = XLSImporter(converters={'a': date_converter, 'b': date_converter, @@ -91,6 +92,21 @@ class ConverterTest(unittest.TestCase): assert df.shape[0] == 2 assert df.a.iloc[0] == df.b.iloc[0] == df.c.iloc[0] + def test_date_xls(self): + """Test with .xlsx in order to check xlrd engine.""" + test_file = os.path.join(os.path.dirname(__file__), "date.xls") + self.importer = XLSImporter(converters={'a': date_converter, + 'b': date_converter, + 'c': partial(date_converter, + fmt="%d.%m.%y") + }, obligatory_columns=['a']) + + xls_file = pd.io.excel.ExcelFile(test_file) + df = xls_file.parse() + df = self.importer.read_xls(test_file) + assert df.shape[0] == 2 + assert df.a.iloc[0] == df.b.iloc[0] == df.c.iloc[0] + def test_inc_date(self): incomplete_date_converter("2020", fmts={"%Y": "%Y"}) == "2020" incomplete_date_converter("02/2020", -- GitLab