@@ -1288,9 +1288,7 @@ def check_exception(failed_task, exception): # pylint: disable=unused-variable
12881288 assert not luigi .build ([failing_task ], local_scheduler = True )
12891289
12901290 assert failed_tasks == [str (failing_task )]
1291- assert exceptions == [
1292- str (IndexError ("The following index values are duplicated: ['0', '1']" ))
1293- ]
1291+ assert exceptions == [str (IndexError ("The following index values are duplicated: [0, 1]" ))]
12941292
12951293 def test_change_index (self , tmpdir , TestTask ):
12961294 """Test that the process fails if the index is changed by the validation function."""
@@ -1743,6 +1741,27 @@ def inputs(self):
17431741 == redirect_stdout
17441742 )
17451743
1744+ @pytest .fixture
1745+ def empty_dataset_df_path (self , tmpdir ):
1746+ """Create an empty CSV dataset and return its path."""
1747+ dataset_df_path = tmpdir / "dataset.csv"
1748+ base_dataset_df = pd .DataFrame ({"a" : [], "b" : []})
1749+ base_dataset_df .to_csv (dataset_df_path )
1750+
1751+ return str (dataset_df_path )
1752+
1753+ def test_defaults_with_empty (self , TestTask , empty_dataset_df_path , tmpdir ):
1754+ """Test that the empty dataset is properly processed."""
1755+ assert luigi .build (
1756+ [TestTask (dataset_df = empty_dataset_df_path , result_path = str (tmpdir / "out" ))],
1757+ local_scheduler = True ,
1758+ )
1759+ result = pd .read_csv (tmpdir / "out" / "TestTask" / "report.csv" )
1760+ assert result ["is_valid" ].tolist () == []
1761+ assert result ["ret_code" ].tolist () == []
1762+ assert result ["comment" ].tolist () == []
1763+ assert result ["exception" ].tolist () == []
1764+
17461765
17471766class TestValidationWorkflow :
17481767 """Test the data_validation_framework.task.ValidationWorkflow class."""
0 commit comments