krrood.entity_query_language.testing.result_generation#
Generates a committed VerbalizationResult snapshot module from a
VerbalizationResultsOfPackage.
Uses CodeGenerator so the module is produced
rather than hand-transcribed: call regenerate_verbalization_results() from a
package’s own conftest.py at import time, so the committed file is always fresh and a
wording change shows up as an ordinary diff to review before committing.
Classes#
Renders the Python source of a |
Functions#
|
Regenerate package's committed |
Module Contents#
- class krrood.entity_query_language.testing.result_generation.VerbalizationResultGenerator#
Renders the Python source of a
resultssnapshot module for aVerbalizationResultsOfPackage.- snapshot: krrood.entity_query_language.testing.result_verification.VerbalizationResultsOfPackage#
The snapshot whose covered callables and renderings this generator emits.
- code_generator: krrood.code_generation.generator.CodeGenerator#
Renderer bound to this package’s templates directory.
- covered_callables() Tuple[Type[krrood.entity_query_language.predicate.SymbolicCallable], ...]#
The callables this generator emits an entry for.
- Returns:
the discovered callables that implement their own verbalization fragment, in the order they appear in the generated module.
- covered_results() Tuple[krrood.entity_query_language.testing.result_verification.VerbalizationResult, ...]#
The data the generated module declares.
- Returns:
one
VerbalizationResultper covered callable, built directly from the snapshot’s own rendering.
- generate() str#
- Returns:
the Python source of a module declaring
results, one
VerbalizationResultper covered callable.
- write(path: str | pathlib.Path) None#
Render
generate()to path and format it with Ruff.- Parameters:
path – The file to write the generated module to.
- krrood.entity_query_language.testing.result_generation.regenerate_verbalization_results(package: types.ModuleType, destination: str | pathlib.Path) None#
Regenerate package’s committed
resultssnapshot module at destination.Writes to a temporary file in destination’s own directory and replaces it atomically, so a concurrent reader (e.g. a pytest-xdist worker) never observes a partially written file. Call this from a package’s own
conftest.pyat import time, so this is a one-line addition for any package, not a bespoke script.- Parameters:
package – The package whose symbolic callables are discovered and rendered.
destination – The module file to (re)write.