Repository navigation
Test code, not the libraries, and run the doctest - #45
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andmodel_copy.test_char_count_is_derived_from_span: Pydantic computed-field serialization and round-trip.char_count == end - startis still asserted bytest_span_slices_section_from_sourceandtest_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) andtest_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_headersandtest_nested_headers(child hash1). Theisinstance(..., dict)check is Pydantic type validation.test_invalid_max_levelstays, because it tests our__post_init__.test_file_operationsgets a docstring in place of its comment.New test:
test_front_matter_needs_yaml_lines_and_a_closing_line, next totest_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"]andaddopts = "--doctest-modules", so thesplit_textdocstring 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
splitter.py98% (missing 76-78). After: 100% for every file.uv run pytest -vv --cov=markdown_chunkify --cov-report=term-missing: 90 passed, doctest collected asmarkdown_chunkify/splitter.py::markdown_chunkify.splitter.MarkdownSplitter.split_text.uv run pytest(release workflow): 90 passed.pydantic==2.0.2and the package installed into the venv: 90 passed, doctest included, no import file mismatch.uv sync --locked,ruff check --no-fix .,ruff format --check .anduv buildpass.