test_wiki_junit_robust.py

tests/test_wiki_junit_robust.py

A JUnit report that is not valid XML is recovered or refused by name (#72 bug 3, 2.1).

test_an_unreadable_report_is_refused_naming_file_and_line

None test_wiki_junit_robust.test_an_unreadable_report_is_refused_naming_file_and_line(Path tmp_path)

Never a raw ParseError: a ValueError with the file, line and column.

tests/test_wiki_junit_robust.py:38

Show on the map →

Called by none

Calls parse_junit

Checks

  • assert "broken.xml" in text and "line" in text

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-002measuredtest_an_unreadable_report_is_refused_naming_file_and_line → parse_junit
REQ-DDB-WIKI-010measuredtest_an_unreadable_report_is_refused_naming_file_and_line → parse_junit → fold_cases
Source · 8 lines
def test_an_unreadable_report_is_refused_naming_file_and_line(tmp_path: Path) -> None:
    """@brief Never a raw ParseError: a ValueError with the file, line and column."""
    report = tmp_path / "broken.xml"
    report.write_text('<testsuite>\n<testcase name="a">\n')
    with pytest.raises(ValueError) as exc:
        parse_junit([report])
    text = str(exc.value)
    assert "broken.xml" in text and "line" in text

1 more lines, not shown

Activity · 6 steps
lines 40–40report = tmp_path / "broken.xml"lines 41–41report.write_text('<testsuite>\n<testcase name="a">\n')lines 42–42with pytest.raises(ValueError) as exclines 43–43parse_junit([report])lines 44–44text = str(exc.value)lines 45–45assert "broken.xml" in text and "line" in text

test_terminal_colour_codes_in_a_report_are_stripped_and_said

None test_wiki_junit_robust.test_terminal_colour_codes_in_a_report_are_stripped_and_said(Path tmp_path, caplog)

ANSI sequences and XML-illegal controls are removed, the count logged, results kept.

tests/test_wiki_junit_robust.py:28

Show on the map →

Called by none

Calls parse_junit

Checks

  • assert results["test_a"].status == "passed" and results["test_b"].status == "failed"
  • assert "ceedling.xml" in caplog.text and "control" in caplog.text

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-002measuredtest_terminal_colour_codes_in_a_report_are_stripped_and_said → parse_junit
REQ-DDB-WIKI-010measuredtest_terminal_colour_codes_in_a_report_are_stripped_and_said → parse_junit → fold_cases
Source · 10 lines
def test_terminal_colour_codes_in_a_report_are_stripped_and_said(tmp_path: Path, caplog) -> None:  # noqa: ANN001
    """@brief ANSI sequences and XML-illegal controls are removed, the count logged, results kept."""
    report = tmp_path / "ceedling.xml"
    report.write_bytes(_COLOURED.encode("utf-8"))
    with caplog.at_level(logging.WARNING):
        results = parse_junit([report])
    assert results["test_a"].status == "passed" and results["test_b"].status == "failed"
    assert "ceedling.xml" in caplog.text and "control" in caplog.text

Activity · 6 steps
lines 30–30report = tmp_path / "ceedling.xml"lines 31–31report.write_bytes(_COLOURED.encode("utf-8"))lines 32–32with caplog.at_level(logging.WARNING)lines 33–33results = parse_junit([report])lines 34–34assert results["test_a"].status == "passed" and results["test_b"].status == "failed"lines 35–35assert "ceedling.xml" in caplog.text and "control" in caplog.text