MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / test_to_html

Method test_to_html

tests/unit/reporting_test.py:194–233  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

192 # ------------------------------------------------------------------ #
193
194 def test_to_html(self):
195 reporter = Reporter([self.test_issue], "html")
196 output = reporter.to_html()
197
198 soup = BeautifulSoup(output, "html.parser")
199
200 self.assertEqual(soup.title.string, "PySpector Scan Report")
201
202 # Check header h1
203 h1 = soup.find("h1")
204 self.assertIsNotNone(h1)
205 self.assertEqual(h1.text.strip(), "PySpector Scan Report")
206
207 # Check header h2
208 h2 = soup.find("h2")
209 self.assertIsNotNone(h2)
210 self.assertIn("Found 1 issues.", h2.text)
211
212 # Check table
213 table = soup.find("table")
214 self.assertIsNotNone(table)
215
216 # Check table header
217 headers = [th.text.strip() for th in table.find_all("th")]
218 expected_headers = ["File", "Line", "Severity", "Description", "Code"]
219 self.assertEqual(headers, expected_headers)
220
221 rows = table.find_all("tr")[1:]
222 self.assertEqual(len(rows), 1)
223
224 # Check result row
225 cells = rows[0].find_all("td")
226 self.assertEqual(cells[0].text.strip(), self.test_issue.file_path)
227 self.assertEqual(cells[1].text.strip(), str(self.test_issue.line_number))
228 self.assertEqual(cells[2].text.strip(), self.test_issue.severity)
229 self.assertEqual(cells[3].text.strip(), self.test_issue.description)
230
231 code_cell = cells[4].find("code")
232 self.assertIsNotNone(code_cell)
233 self.assertEqual(code_cell.text.strip(), self.test_issue.code)
234
235 def test_to_html_issue_count_in_header(self):
236 issues = [_make_issue(rule_id=f"PY{i:03d}") for i in range(3)]

Callers

nothing calls this directly

Calls 2

to_htmlMethod · 0.95
ReporterClass · 0.90

Tested by

no test coverage detected