1515
1616class TestValidationResult :
1717 """Test ValidationResult dataclass."""
18-
18+
1919 def test_result_creation (self ):
2020 """Test basic result creation."""
2121 result = ValidationResult (
@@ -25,11 +25,11 @@ def test_result_creation(self):
2525 install_commands_worked = ["pip install -e ." ],
2626 test_results = {"base:pytest" : False , "patch:pytest" : True },
2727 )
28-
28+
2929 assert result .passed is True
3030 assert result .phase == "complete"
3131 assert len (result .install_commands_worked ) == 1
32-
32+
3333 def test_result_to_dict (self ):
3434 """Test result serialization."""
3535 result = ValidationResult (
@@ -39,34 +39,34 @@ def test_result_to_dict(self):
3939 error_message = "Install failed" ,
4040 install_commands_failed = ["pip install -e ." ],
4141 )
42-
42+
4343 data = result .to_dict ()
44-
44+
4545 assert data ["task_id" ] == "test-002"
4646 assert data ["passed" ] is False
4747 assert data ["error_message" ] == "Install failed"
48-
48+
4949 def test_failed_install_tracking (self ):
5050 """Test tracking of failed install commands."""
5151 result = ValidationResult (task_id = "test-003" , passed = False , phase = "install" )
52-
52+
5353 result .install_commands_worked .append ("apt-get update" )
5454 result .install_commands_failed .append ("pip install broken-package" )
55-
55+
5656 assert len (result .install_commands_worked ) == 1
5757 assert len (result .install_commands_failed ) == 1
5858
5959
6060class TestDatasetValidationReport :
6161 """Test DatasetValidationReport."""
62-
62+
6363 def test_empty_report (self ):
6464 """Test empty report."""
6565 report = DatasetValidationReport ()
66-
66+
6767 assert report .total_tasks == 0
6868 assert report .pass_rate == 0.0
69-
69+
7070 def test_report_with_results (self ):
7171 """Test report with validation results."""
7272 report = DatasetValidationReport (
@@ -76,40 +76,45 @@ def test_report_with_results(self):
7676 validation_results = [
7777 ValidationResult (task_id = "t1" , passed = True , phase = "complete" ),
7878 ValidationResult (task_id = "t2" , passed = True , phase = "complete" ),
79- ValidationResult (task_id = "t3" , passed = False , phase = "test_base" , error_message = "Test failed" ),
79+ ValidationResult (
80+ task_id = "t3" ,
81+ passed = False ,
82+ phase = "test_base" ,
83+ error_message = "Test failed" ,
84+ ),
8085 ],
8186 )
82-
83- assert report .pass_rate == 2 / 3
87+
88+ assert report .pass_rate == 2 / 3
8489 assert report .failed_tasks == 1
85-
90+
8691 def test_report_to_json (self ):
8792 """Test report JSON serialization."""
8893 report = DatasetValidationReport (
8994 total_tasks = 2 ,
9095 passed_tasks = 1 ,
9196 failed_tasks = 1 ,
9297 )
93-
98+
9499 json_str = report .to_json ()
95100 data = json .loads (json_str )
96-
101+
97102 assert data ["total_tasks" ] == 2
98103 assert data ["pass_rate" ] == 0.5
99104
100105
101106class TestPrintValidationReport :
102107 """Test print_validation_report function."""
103-
108+
104109 def test_print_empty_report (self , capsys ):
105110 """Test printing empty report."""
106111 report = DatasetValidationReport ()
107112 print_validation_report (report )
108-
113+
109114 captured = capsys .readouterr ()
110115 assert "Total tasks: 0" in captured .out
111116 assert "Pass rate:" in captured .out
112-
117+
113118 def test_print_report_with_results (self , capsys ):
114119 """Test printing report with results."""
115120 report = DatasetValidationReport (
@@ -119,16 +124,16 @@ def test_print_report_with_results(self, capsys):
119124 validation_results = [
120125 ValidationResult (task_id = "t1" , passed = True , phase = "complete" ),
121126 ValidationResult (
122- task_id = "t2" ,
123- passed = False ,
127+ task_id = "t2" ,
128+ passed = False ,
124129 phase = "test_base" ,
125- error_message = "Test failed on base"
130+ error_message = "Test failed on base" ,
126131 ),
127132 ],
128133 )
129-
134+
130135 print_validation_report (report )
131-
136+
132137 captured = capsys .readouterr ()
133138 assert "Passed: 3" in captured .out
134139 assert "Failed: 2" in captured .out
@@ -137,7 +142,7 @@ def test_print_report_with_results(self, capsys):
137142
138143class TestSweTaskInstallConfig :
139144 """Test SweTask with install_config field."""
140-
145+
141146 def test_task_with_install_config (self ):
142147 """Test task creation with install_config."""
143148 task = SweTask (
@@ -152,10 +157,10 @@ def test_task_with_install_config(self):
152157 "validated" : True ,
153158 },
154159 )
155-
160+
156161 assert task .install_config ["python_version" ] == "3.11"
157162 assert task .install_config ["package_manager" ] == "poetry"
158-
163+
159164 def test_task_is_install_ready (self ):
160165 """Test is_install_ready method."""
161166 # Not ready
@@ -164,7 +169,7 @@ def test_task_is_install_ready(self):
164169 install_config = {},
165170 )
166171 assert task1 .is_install_ready () is False
167-
172+
168173 # Ready
169174 task2 = SweTask (
170175 id = "test-002" ,
0 commit comments