Assertions framework for BabelTest expectations (2/4)#102
Open
gaurav wants to merge 4 commits into
Open
Conversation
Introduce src/babel_validation/assertions: a small framework of handler classes that turn a named BabelTest assertion (HasLabel, SearchByName, ResolvesWith, DoesNotResolveWith, ResolvesWithType, Needed, ...) plus its parameters into a check evaluated against NodeNorm/NameRes, returning a TestResult. assertions/README.md is generated from the handler class attributes by gen_docs.py, and test_assertions_docs.py (marked `unit`, offline) asserts the checked-in README stays in sync. Register the `unit` marker, first used by that test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 26, 2026
…path
- ResolvesWithTypeHandler: use node.get('type') or [] instead of node['type']
to match the existing first_type() guard (NodeNorm can return results without
a type key)
- NeededHandler: add test_with_nameres override so Needed issues fail on both
NodeNorm and NameRes paths, not just NodeNorm
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove drug_chemical_conflate='true' from the NodeNorm call used to
canonicalize the expected CURIE; NameRes normalizes without conflation, so
using it caused structural false failures for drug/chemical CURIEs
- Use .get('label', '') instead of ['label'] to avoid KeyError for CURIEs
that NodeNorm resolves without a preferred label
- Regenerate assertions/README.md to reflect the updated parameter description
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ionHandler - AssertionHandler.test_with_nodenorm/test_with_nameres: return iter([]) instead of [] to match the Iterator[TestResult] annotation; simplify docstrings to remove reference to github_issues_test_cases.py (module not yet in this PR) - Remove same stale reference from NodeNormTest.test_param_set and NameResTest.test_param_set docstrings - SearchByNameHandler.DESCRIPTION: "exactly two" not "at least two" to match the len(params) != 2 enforcement in test_param_set - Regenerate assertions/README.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Stack 2 of 4 splitting #67. Base:
split/1-library-reorg(PR #101) — review/merge that first.Adds
src/babel_validation/assertions: the engine that turns a named BabelTest assertion + its parameters into a check evaluated against NodeNorm/NameRes.What changes
HasLabel,SearchByName,ResolvesWith,DoesNotResolveWith,ResolvesWithType,Needed, … each declaring its params and producing aTestResult.gen_docs.pygeneratesassertions/README.mdfrom the handler class attributes;tests/test_environment/test_assertions_docs.py(offline,unit) asserts the checked-in README stays in sync.unitpytest marker (first used by that test).Depends only on PR #101's
core+services— no GitHub/network code here.Verify
uv run pytest -m unit -q→ assertions docs test passes offline.uv run python -m src.babel_validation.assertions.gen_docsreproduces the committed README.🤖 Generated with Claude Code