docs: document caplog, capsys, capfd, recwarn, tmp_path_factory built-in fixtures#664
Merged
MatthewMckee4 merged 1 commit intomainfrom Apr 11, 2026
Merged
docs: document caplog, capsys, capfd, recwarn, tmp_path_factory built-in fixtures#664MatthewMckee4 merged 1 commit intomainfrom
MatthewMckee4 merged 1 commit intomainfrom
Conversation
fa12357 to
01d1bdd
Compare
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.
Summary
The built-in fixtures page at
docs/usage/fixtures/builtin.mdonly documentedtmp_pathandmonkeypatch, but since alpha.4 Karva has shipped several more built-in fixtures that are fully implemented and integration-tested:caplog,capsys,capfd,capsysbinary,capfdbinary,recwarn, and the session-scopedtmp_path_factory/tmpdir_factory. None of them were discoverable from the docs, so users looking for pytest-equivalents had no way to find them short of reading the source. This PR closes that gap.The new sections follow the existing tone and structure of the page. Each fixture gets a short description of what it does, a note about which names are accepted (where there are multiple aliases), and one or two minimal runnable examples lifted directly from the integration tests in
crates/karva/tests/it/extensions/fixtures/builtins.rs— so everything documented is behaviour the test suite already pins down.For
caplog, the page explainsat_levelvsset_leveland walks throughrecords,messages,record_tuples, andtext:For
capsys, the page coversreadouterr(), the fact that log messages are captured through stderr, and thecapsys.disabled()context manager.capfdis documented as the file-descriptor-level counterpart, andcapsysbinary/capfdbinaryget a shorter section that points out the only difference (.out/.errarebytes).recwarnis documented as a list-like container withpop(category)andclear().tmp_path_factoryis slotted in right aftertmp_pathand notes that it is session-scoped, so it can be consumed by longer-lived user fixtures —tmp_pathitself is function-scoped and cannot.Test Plan
uvx prek run -apasses clean (markdownlint-fix, mdformat, typos, and the rest).crates/karva/tests/it/extensions/fixtures/builtins.rs, so the documented behaviour is what the test suite already asserts.