[test] CI always skips 5 optional-dependency tests, so two fallback paths never run

Author: wgm66Created Sep 19, 2026Updated Sep 29, 2026
Labelshelp wantedgithub_actions

Problem

python3 -m pytest tests/ -q in CI always reports 5 skipped, because the only thing CI installs is pytest (ci.yml:28) and ruff (ci.yml:41). Those 5 tests are gated by pytest.importorskip:

Site Dep
tests/test_html_block_boundaries.py:131 bs4
tests/test_html_boilerplate_extraction.py:32, 38, 47, 56 trafilatura

The consequence is that production fallback behaviour is asserted nowhere in CI — the very behaviour those tests exist to pin.

Measured (Ubuntu 20.04, Python 3.9.5, same tree, same interpreter otherwise)

pytest tests/ -q                       -> 698 passed,  5 skipped     (ci.yml today: pytest only)
pytest tests/ -q  (bs4 + trafilatura)  -> 703 passed,  0 skipped

The skip is purely dependency-gated, proven by flipping one dep at a time:

bs4 present, trafilatura absent -> TestConvergenceWithBeautifulSoup  1 passed
                                    test_html_boilerplate_extraction  1 passed, 4 skipped
trafilatura present, bs4 absent -> test_html_boilerplate_extraction  5 passed
                                    TestConvergenceWithBeautifulSoup  1 skipped

Why this is worth a CI leg rather than "just an optional dep"

The 4 trafilatura-gated tests are not tests of trafilatura. They patch("trafilatura.extract", ...) and assert the fallback contract of extract_html_content() — returns-None, whitespace-only, and raises must each fall through to bs4. importorskip is used only so the patch target exists; the assertions are about our code. The module docstring is explicit that trafilatura's own heuristics are deliberately not tested here.

So today: three extract_html_content() fallback branches and one bs4 convergence check are written, reviewed, and never executed in CI.

Proposed change

One extra CI leg (or a marker), installing only test-time deps:

yaml
optional-deps:
  name: test (optional deps installed)
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@...
    - uses: actions/setup-python@...
      with: { python-version: "3.12" }
    - run: pip install pytest beautifulsoup4 trafilatura
    - run: pytest tests/ -q

Kept separate from the existing dependency-free smoke job, which is a deliberate and valuable property that this change does not touch.

How would we know it's better?

  • Before: that leg reports 698 passed, 5 skipped; the 5 named tests never run.
  • After: the leg reports 703 passed, 0 skipped, and the 5 tests execute. The existing dependency-free job is unchanged, so nothing is lost.
  • Cost is bounded and measurable: one extra job, three pip installs, no runtime dependency added — beautifulsoup4/trafilatura stay test-only, consistent with the cost discipline in AGENTS.md.

Alternatives considered

  • Leave it as-is: defensible (dependency-free CI is a feature). Then the honest fix is to mark those tests @pytest.mark.optional and document that they never run in CI, rather than leaving a green suite that implies they do.
  • Install the deps in the existing test matrix: would make 5 legs pay for it and weaken the dependency-free guarantee; one dedicated leg is cheaper.
  • Remove the importorskip gates: they would fail on a clean checkout instead of skipping, which is worse.

Source: virgiliojr94/book-to-skill