Skip to content

Test code, not the libraries, and run the doctest - #45

Merged
Gal-Gilor merged 1 commit into
mainfrom
test/cleanup
Oct 18, 2026
Merged

Gal-Gilor merged 1 commit into
mainfrom
test/cleanup

Conversation

@Gal-Gilor

@Gal-Gilor Gal-Gilor commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

What changed

Deleted tests that only check library behavior:

  • test_parents_reject_none: Pydantic type validation.
  • test_metadata_requires_id: Pydantic required-field validation.
  • test_models_are_frozen: Pydantic frozen config and model_copy.
  • test_char_count_is_derived_from_span: Pydantic computed-field serialization and round-trip. char_count == end - start is still asserted by test_span_slices_section_from_source and test_span_offsets.
  • test_splitter_is_keyword_only_and_frozen: stdlib dataclass keyword-only and frozen behavior.

Deleted redundant tests, whose assertions other tests already make:

  • test_single_header: test_byte_order_mark_in_text (one section, level 1, header) and test_keeps_source_text (header and content of a single section).
  • test_level_counting: test_levels_up_to_six (levels 1 to 6).
  • test_metadata_structure: test_breadcrumb (a top-level section's breadcrumb is only its own header, so its parents are empty), test_parent_headers and test_nested_headers (child has h1). The isinstance(..., dict) check is Pydantic type validation.

test_invalid_max_level stays, because it tests our __post_init__. test_file_operations gets a docstring in place of its comment.

New test: test_front_matter_needs_yaml_lines_and_a_closing_line, next to test_front_matter_must_start_with_a_key. It covers a --- block that starts with a key but has a non-YAML line, and one that is never closed. Both are not front matter, so their headers are split. These were the uncovered lines 76-78 in _front_matter_line_count.

pytest config: testpaths = ["tests", "markdown_chunkify"] and addopts = "--doctest-modules", so the split_text docstring example runs with every pytest run.

No library code changes. No CHANGELOG entry, because nothing user-facing changes.

Why

Test our code, not Pydantic or the standard library. The deleted tests checked library mechanics or repeated other tests. The docstring example was not run, so it could go stale.

Verification

  • Coverage before: 99% total, splitter.py 98% (missing 76-78). After: 100% for every file.
  • Tests before: 95 passed. After: 90 passed (95 - 8 deleted + 2 new cases + 1 doctest).
  • Each new case was checked on its own: the non-YAML case covers line 76, the unclosed case covers line 78.
  • uv run pytest -vv --cov=markdown_chunkify --cov-report=term-missing: 90 passed, doctest collected as markdown_chunkify/splitter.py::markdown_chunkify.splitter.MarkdownSplitter.split_text.
  • uv run pytest (release workflow): 90 passed.
  • Lowest supported pydantic job, replicated with Python 3.12, pydantic==2.0.2 and the package installed into the venv: 90 passed, doctest included, no import file mismatch.
  • uv sync --locked, ruff check --no-fix ., ruff format --check . and uv build pass.

Delete tests that only check Pydantic or dataclass behavior, and tests
whose assertions other tests already make. Add a front matter test that
covers the non-YAML line and unclosed block paths. Run the split_text
docstring example with every pytest run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018jNL9rsodv5SMpDXVNMEia
@Gal-Gilor Gal-Gilor changed the title Test our code, not the libraries, and run the doctest Test code, not the libraries, and run the doctest Oct 18, 2026
@Gal-Gilor
Gal-Gilor merged commit cd449fe into main Oct 18, 2026
5 checks passed
@Gal-Gilor
Gal-Gilor deleted the test/cleanup branch October 18, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants