|
@@ -31,7 +31,12 @@ def tmp_excel_file():
|
|
|
def cleanup(tmp_excel_file):
|
|
|
yield
|
|
|
if os.path.exists(tmp_excel_file):
|
|
|
- os.remove(tmp_excel_file)
|
|
|
+ try:
|
|
|
+ os.remove(tmp_excel_file)
|
|
|
+ except Exception as e:
|
|
|
+ from taipy.logger._taipy_logger import _TaipyLogger
|
|
|
+ logger = _TaipyLogger._get_logger()
|
|
|
+ logger.error(f"Failed to delete {tmp_excel_file}. {e}")
|
|
|
|
|
|
|
|
|
@dataclasses.dataclass
|
|
@@ -161,39 +166,39 @@ def test_write_with_header_multiple_sheet_numpy_without_sheet_name(tmp_excel_fil
|
|
|
assert np.array_equal(excel_dn_data[sheet_name], sheet_data[sheet_name])
|
|
|
|
|
|
|
|
|
-# def test_write_with_header_multiple_sheet_custom_exposed_type_with_sheet_name(tmp_excel_file):
|
|
|
-# excel_dn = ExcelDataNode(
|
|
|
-# "foo",
|
|
|
-# Scope.SCENARIO,
|
|
|
-# properties={"path": tmp_excel_file, "sheet_name": sheet_names, "exposed_type": MyCustomObject},
|
|
|
-# )
|
|
|
-# row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
-# row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
-# sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
-#
|
|
|
-# excel_dn.write(sheet_data)
|
|
|
-# excel_dn_data = excel_dn.read()
|
|
|
-# assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
-# for sheet_name in sheet_data.keys():
|
|
|
-# assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
-#
|
|
|
-#
|
|
|
-# def test_write_with_header_multiple_sheet_custom_exposed_type_without_sheet_name(tmp_excel_file):
|
|
|
-# excel_dn = ExcelDataNode(
|
|
|
-# "foo",
|
|
|
-# Scope.SCENARIO,
|
|
|
-# properties={"path": tmp_excel_file, "exposed_type": MyCustomObject})
|
|
|
-#
|
|
|
-# row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
-# row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
-# sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
-#
|
|
|
-# excel_dn.write(sheet_data)
|
|
|
-# excel_dn_data = excel_dn.read()
|
|
|
-# assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
-# for sheet_name in sheet_data.keys():
|
|
|
-# assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
-#
|
|
|
+def test_write_with_header_multiple_sheet_custom_exposed_type_with_sheet_name(tmp_excel_file):
|
|
|
+ excel_dn = ExcelDataNode(
|
|
|
+ "foo",
|
|
|
+ Scope.SCENARIO,
|
|
|
+ properties={"path": tmp_excel_file, "sheet_name": sheet_names, "exposed_type": MyCustomObject},
|
|
|
+ )
|
|
|
+ row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
+ row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
+ sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
+
|
|
|
+ excel_dn.write(sheet_data)
|
|
|
+ excel_dn_data = excel_dn.read()
|
|
|
+ assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
+ for sheet_name in sheet_data.keys():
|
|
|
+ assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
+
|
|
|
+
|
|
|
+def test_write_with_header_multiple_sheet_custom_exposed_type_without_sheet_name(tmp_excel_file):
|
|
|
+ excel_dn = ExcelDataNode(
|
|
|
+ "foo",
|
|
|
+ Scope.SCENARIO,
|
|
|
+ properties={"path": tmp_excel_file, "exposed_type": MyCustomObject})
|
|
|
+
|
|
|
+ row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
+ row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
+ sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
+
|
|
|
+ excel_dn.write(sheet_data)
|
|
|
+ excel_dn_data = excel_dn.read()
|
|
|
+ assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
+ for sheet_name in sheet_data.keys():
|
|
|
+ assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
+
|
|
|
|
|
|
def test_write_without_header_multiple_sheet_pandas_with_sheet_name(tmp_excel_file):
|
|
|
excel_dn = ExcelDataNode(
|
|
@@ -313,46 +318,46 @@ def test_write_without_header_multiple_sheet_numpy_without_sheet_name(tmp_excel_
|
|
|
assert np.array_equal(excel_dn_data[sheet_name], sheet_data[sheet_name])
|
|
|
|
|
|
|
|
|
-# def test_write_without_header_multiple_sheet_custom_exposed_type_with_sheet_name(tmp_excel_file):
|
|
|
-# excel_dn = ExcelDataNode(
|
|
|
-# "foo",
|
|
|
-# Scope.SCENARIO,
|
|
|
-# properties={
|
|
|
-# "path": tmp_excel_file,
|
|
|
-# "sheet_name": sheet_names,
|
|
|
-# "exposed_type": MyCustomObject,
|
|
|
-# "has_header": False,
|
|
|
-# },
|
|
|
-# )
|
|
|
-#
|
|
|
-# row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
-# row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
-# sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
-#
|
|
|
-# excel_dn.write(sheet_data)
|
|
|
-# excel_dn_data = excel_dn.read()
|
|
|
-# assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
-# for sheet_name in sheet_data.keys():
|
|
|
-# assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
-#
|
|
|
-#
|
|
|
-# def test_write_without_header_multiple_sheet_custom_exposed_type_without_sheet_name(tmp_excel_file):
|
|
|
-# excel_dn = ExcelDataNode(
|
|
|
-# "foo",
|
|
|
-# Scope.SCENARIO,
|
|
|
-# properties={"path": tmp_excel_file, "exposed_type": MyCustomObject, "has_header": False}
|
|
|
-# )
|
|
|
-#
|
|
|
-# row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
-# row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
-# sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
-#
|
|
|
-# excel_dn.write(sheet_data)
|
|
|
-# excel_dn_data = excel_dn.read()
|
|
|
-# assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
-# for sheet_name in sheet_data.keys():
|
|
|
-# assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
-#
|
|
|
+def test_write_without_header_multiple_sheet_custom_exposed_type_with_sheet_name(tmp_excel_file):
|
|
|
+ excel_dn = ExcelDataNode(
|
|
|
+ "foo",
|
|
|
+ Scope.SCENARIO,
|
|
|
+ properties={
|
|
|
+ "path": tmp_excel_file,
|
|
|
+ "sheet_name": sheet_names,
|
|
|
+ "exposed_type": MyCustomObject,
|
|
|
+ "has_header": False,
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
+ row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
+ sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
+
|
|
|
+ excel_dn.write(sheet_data)
|
|
|
+ excel_dn_data = excel_dn.read()
|
|
|
+ assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
+ for sheet_name in sheet_data.keys():
|
|
|
+ assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
+
|
|
|
+
|
|
|
+def test_write_without_header_multiple_sheet_custom_exposed_type_without_sheet_name(tmp_excel_file):
|
|
|
+ excel_dn = ExcelDataNode(
|
|
|
+ "foo",
|
|
|
+ Scope.SCENARIO,
|
|
|
+ properties={"path": tmp_excel_file, "exposed_type": MyCustomObject, "has_header": False}
|
|
|
+ )
|
|
|
+
|
|
|
+ row_1 = [MyCustomObject(0, 1, "hi"), MyCustomObject(1, 2, "world"), MyCustomObject(2, 3, "text")]
|
|
|
+ row_2 = [MyCustomObject(0, 4, "hello"), MyCustomObject(1, 5, "abc"), MyCustomObject(2, 6, ".")]
|
|
|
+ sheet_data = {"Sheet1": row_1, "Sheet2": row_2}
|
|
|
+
|
|
|
+ excel_dn.write(sheet_data)
|
|
|
+ excel_dn_data = excel_dn.read()
|
|
|
+ assert len(excel_dn_data) == len(sheet_data) == 2
|
|
|
+ for sheet_name in sheet_data.keys():
|
|
|
+ assert all(actual == expected for actual, expected in zip(excel_dn_data[sheet_name], sheet_data[sheet_name]))
|
|
|
+
|
|
|
|
|
|
@pytest.mark.skip(reason="Not implemented on pandas 1.3.5")
|
|
|
@pytest.mark.parametrize(
|