Skip to content

test(suite): share write_json, mark slow tests and move Rainbond tests - #237

Merged
lanyue-llk merged 1 commit into
mainfrom
test/tidy-suite-structure
Nov 4, 2026
Merged

lanyue-llk merged 1 commit into
mainfrom
test/tidy-suite-structure

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #105

The issue was narrowed in its latest comment to these four items; the private-import sweep is dropped.

Summary

  • Shared helper: tests/helpers.py holds one write_json, replacing 15 copies. It creates the parent directory, writes UTF-8 JSON with a trailing newline, and returns the path. The Lexbench report fixture keeps a one-line wrapper that returns the file hash, because its callers bind that digest; test_lexbench_report_runtime.py now imports that wrapper instead of its own copy.
  • Package smoke: this gate loads fixtures from the checkout with runpy, so those fixtures need tests.helpers to resolve. tests/package_smoke.py now appends the checkout to sys.path. The source uses a src layout, so harness still resolves to the installed distribution, and the existing "outside the checkout" assertions still run.
  • slow marker: registered in pyproject.toml and applied to 12 test functions (19 collected tests) that each took about 8 seconds or more in a measured full run (--durations=60). The golden report tests were left unmarked because they should always run. CI is unchanged and still runs the slow tests. CONTRIBUTING.md documents -m "not slow".
  • Behaviour test: test_local_audit_banner_has_no_pull_request_number now asserts on the rendered banner, including its English attribute, instead of reading report.py and report_i18n.py source text.
  • Rainbond tests: test_rainbond_slices.py and test_rainbond_live_smoke.py moved from tests/trajectory_replay/public_webarena/ to tests/environments/. The README command path is updated, and make public-webarena-report-audit names the slice tests explicitly so that target keeps running them.

The other public_webarena tests that mention Rainbond exercise the public WebArena environment wiring and stay where they are. The golden snapshots are unchanged.

Test plan

  • Lint gate (ruff check --select F,TID252 over all Python, then ruff check): passed.
  • tests/test_golden_reports.py: 17 passed on the final commit, no snapshot changes.
  • Full local suite excluding real_smoke, before and after the change: 91 failed before, 89 failed after, and no test failed only after. The two that failed only before are in test_moli_provider.py, which this change does not touch; I did not investigate why they flipped.
  • The high local failure counts appear to come from the setup: they do not grow with this change. I could not set PYTHONPATH here and used pytest's -o 'pythonpath=src .' instead, which does not reach subprocesses. Tests that spawn python -m harness... therefore ran another checkout's code. I confirmed that cause on the four failures I inspected (for example invalid choice: 'wcxb-score'), but did not triage all 89 individually.
  • tests/package_smoke.py was not run locally because it needs a clean install. The "Installation and packaging" check is the test for the sys.path change.
  • Linux CI is the authoritative result for the suite.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · 0573ae4

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review, round 1

Head reviewed: 0573ae43. No defects found. No P0, P1, P2 or P3 findings.

What I verified

Helper swap

  • I compared all removed write_json and _write_json copies with tests/helpers.py. The copies differed in three ways: ensure_ascii, the trailing newline, and indent=2 in test_assemble_webfetch_refresh.py. The helper also adds mkdir where some copies had none.
  • No test depended on those bytes. The changed test modules passed, with the known local failures noted below, and tests/test_golden_reports.py passed without snapshot changes.
  • No references to the removed self.write_json or _write_json test helpers remain. fixture['write_json'] in tests/package_smoke.py still resolves through the fixture's module globals.

Over-design

  • The obvious simpler form is the existing harness.record_io.write_json. I tried it behind the helper in a scratch copy, and it is not a drop-in replacement.
  • Its indented output changes fixture hashes. With parents=True, the WCXB and Lexbench golden report tests fail, as does test_report_builds_are_byte_identical_under_an_ascii_locale. With parents=False, many more tests fail.
  • The compact helper therefore preserves the snapshots. The Lexbench wrapper that returns a hash is one line and its callers use the digest.

tests/package_smoke.py

  • sys.path.append runs after the "outside the checkout" assertion and places the checkout after site-packages. The repository root has no harness directory because of the src layout.
  • No live code under src/ imports top-level tests or scripts. The only match is a frozen .py.txt data file.
  • CI's "Installation and packaging" job runs make package-check, and that job passed.

Behaviour test

  • test_local_audit_banner_has_no_pull_request_number fails when PR #30 is injected into the banner.
  • It also fails when the English attribute is removed.

slow marker

  • -m slow collects 19 tests, matching the PR description.
  • make -n test-python PYTEST_ARGS='-m "not slow"' keeps the quoting intact.
  • CI passes no -m expression, so it still runs these tests.

Rainbond move

  • Both files are pure renames with no path dependence on their old directory.
  • The only conftest.py is tests/conftest.py, so the move loses no fixtures.
  • The old test paths have no remaining references. The Makefile audit target still collects the slice tests.
  • The Rainbond tests that stay in public_webarena exercise WebArenaEnvironment wiring and example templates, so leaving them there is reasonable.

Scope

  • The issue's latest comment narrows it to the four items this PR delivers, so Closes #105 is accurate.
  • The PR touches no workflow files, evidence or profiles.

Test results (local)

  • Both lint gate commands passed.
  • Changed test modules plus tests/test_golden_reports.py, excluding real_smoke: 733 passed, 4 skipped, 2 failed.
  • Both failures are on the known local-failure list and neither is caused by this PR:
    • test_current_dataset_registry_and_profile_are_one_complete_matrix
    • test_zillow_full_score_requires_distinct_numeric_card_fields[3 beds · 2.5 baths · 1,200 sqft-True]
  • I did not run the full suite locally or tests/package_smoke.py. For those I rely on CI.

CI on the current head

All checks pass: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks", "Python 3.11", "Select check scope", "OCR dispatch" and ocr-review.

lanyue-llk added a commit that referenced this pull request Nov 4, 2026
lanyue-llk added a commit that referenced this pull request Nov 4, 2026
@lanyue-llk
lanyue-llk force-pushed the test/tidy-suite-structure branch from 0573ae4 to 722408f Compare November 4, 2026 09:25

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · 722408f

No findings in this review.

@lanyue-llk
lanyue-llk merged commit f1dcafc into main Nov 4, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the test/tidy-suite-structure branch November 4, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up test-suite structure

1 participant