Library API: Assertion object model + run_issue_tests reporting API#96
Open
gaurav wants to merge 2 commits into
Open
Library API: Assertion object model + run_issue_tests reporting API#96gaurav wants to merge 2 commits into
gaurav wants to merge 2 commits into
Conversation
Rename GitHubIssueTest -> Assertion (with a back-compat alias) and stop storing the live PyGitHub Issue: capture the few fields actually needed (issue_id, url, state) as plain strings at construction. This makes the object picklable and trivial to build in tests or other tools, and gives downstream consumers a stable, low-level-free surface to interact with. Also adds: - `name`/`is_known` convenience accessors. - `run()`, which yields (param_set, TestResult) pairs by evaluating one param_set at a time, so callers can attribute every result back to its source param_set (CachedNodeNorm/CachedNameRes dedupe the network calls, so it's no slower). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the issue-test orchestration out of the pytest test into a reusable, pytest-free runner so other tools (e.g. Babel Explorer) can "run all issue tests against NodeNorm X / NameRes Y and report pass/fail + messages": - babel_validation/runner.py: run_issue_tests() / run_assertions() returning IssueReport + ResultRecord. The library now owns the expectation rules — open issue => expected-fail (all-pass => `closeable`), closed issue => expected-pass (any-fail => `reopened`) — instead of burying them in the test. - babel_validation/__init__.py: export the public surface (Assertion, GitHubIssuesTestCases, run_issue_tests, run_assertions, IssueReport, ResultRecord, CachedNodeNorm, CachedNameRes, TestResult, TestStatus). - tests/github_issues/test_github_issues.py: now a thin adapter that maps an IssueReport onto pytest outcomes (xfail/subtests/skip/fail); behavior unchanged. - tests/github_issues/test_runner.py: offline unit tests for the runner using fake services, also exercising the public import surface. - README: "Use as a library" section with the Explorer (run_issue_tests) and Babel (parse + custom executor) usage examples. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR evolves the GitHub-issue-driven test framework into a more library-friendly API by introducing a picklable Assertion object model and a pytest-independent execution/reporting layer (run_assertions / run_issue_tests) that downstream tools can consume.
Changes:
- Introduces
Assertion(with a back-compat alias) that stores only plain issue metadata and provides arun()method yielding per-param_setresults. - Adds
babel_validation.runnerwithIssueReport/ResultRecordplus orchestration helpers for library consumers, and rewires pytest to act as a thin adapter. - Exposes a public import surface via
babel_validation.__init__, adds offline runner unit tests, and documents library usage in the README.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/github_issues/test_system.py | Updates a test comment to reflect Assertion rename. |
| tests/github_issues/test_runner.py | Adds offline unit coverage for the new runner/reporting layer and public API imports. |
| tests/github_issues/test_github_issues.py | Refactors pytest integration into a thin adapter over run_assertions. |
| src/babel_validation/sources/github/github_issues_test_cases.py | Introduces Assertion, stops retaining live PyGitHub Issue, and adds run() for per-param-set execution. |
| src/babel_validation/runner.py | Adds pytest-independent execution/reporting API (IssueReport, ResultRecord, run_*). |
| src/babel_validation/init.py | Defines and exports the library’s public API surface. |
| README.md | Adds “Use as a library” documentation and examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+68
to
+70
| `{{BabelTest|...}}` or ```` ```yaml babel_tests: ```` syntax — see | ||
| [`assertions/README.md`](./src/babel_validation/assertions/README.md)), so the library | ||
| needs a GitHub token to fetch them. |
Comment on lines
+121
to
+127
| handler = self._get_handler() | ||
| for param_set in self.param_sets: | ||
| for result in itertools.chain( | ||
| handler.test_with_nodenorm([param_set], nodenorm, label=str(self)), | ||
| handler.test_with_nameres([param_set], nodenorm, nameres, pass_if_found_in_top, label=str(self)), | ||
| ): | ||
| yield param_set, result |
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.
Stacked on #95 (base branch is
library-packaging), which is itself stacked on #67. This is the second of two follow-up PRs making the GitHub-issue test framework usable as a library; see #67 for how they relate. Review #95 first.This PR gives downstream tools (the Babel pipeline and Babel Explorer) a clean object model and a pytest-independent way to run issue tests and report results.
Changes
GitHubIssueTest→Assertion(back-compat alias kept). Stop storing the live PyGitHubIssue; capture the few fields actually used (issue_id,url,state) as plain strings at construction, so the object is picklable and trivial to build in tests/other tools. Addsname/is_knownaccessors andrun(), which yields(param_set, TestResult)pairs (running one param_set at a time so every result is attributable to its source; the cached clients dedupe the network calls).babel_validation/runner.py:run_issue_tests()/run_assertions()returningIssueReport+ResultRecord. The library now owns the expectation rules — open issue ⇒ expected-fail (all-pass ⇒closeable), closed issue ⇒ expected-pass (any-fail ⇒reopened) — instead of burying them in the pytest test.babel_validation/__init__.py: export the public surface (Assertion,GitHubIssuesTestCases,run_issue_tests,run_assertions,IssueReport,ResultRecord,CachedNodeNorm,CachedNameRes,TestResult,TestStatus).tests/github_issues/test_github_issues.py: now a thin adapter that maps anIssueReportonto pytest outcomes (xfail/subtests/skip/fail) — behavior unchanged.tests/github_issues/test_runner.py: offline unit tests for the runner with fake services, also exercising the public import surface.run_issue_tests) and Babel (parse + custom executor) usage examples.Two consumer use-cases this enables
run_issue_tests(...)→IssueReports.Assertions and run them against local DuckDB/JSON with a custom executor (readsassertion/param_sets), to flag closeable/reopened issues before data reaches NodeNorm.Verification
uv run pytest -m unit→ green (57 passed: 49 existing + 8 new runner tests).uv buildshipsbabel_validation/runner.pyand the populated__init__;from babel_validation import Assertion, run_issue_testsworks.Follow-up ideas (out of scope; tracked separately)
Library-usability improvements identified during this work, deliberately left out of these PRs:
py.typedmarker so consumers get type-checking🤖 Generated with Claude Code