Skip to content

Test the package's exports, version agreement, reason constants and non-mapping tags - #18

Merged
dmccoystephenson merged 1 commit into
mainfrom
trace/test-public-surface
Oct 18, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
trace/test-public-surface

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Stage B (unit-test expansion) cycle: characterization tests are added for the package's public surface and release identity, which until now were guarded only by convention. No production code is changed.

Summary

  • test_every_place_the_version_is_written_agrees_with_version — both module headers (trace_client/trace_client.py, trace_client/__init__.py) and pyproject.toml are checked to name __version__, so a release that bumps one place and not the others fails CI instead of shipping a vendored file that names two versions.
  • test_the_package_exports_every_public_name_of_the_module — trace_client.__all__ is checked to equal the module's own public names (plus __version__), each re-exported as the same object, so a public constant added to the single-file distribution cannot be silently missing from the package import.
  • test_disabled_reason_values_are_the_exported_constants — REASON_ENVIRONMENT / REASON_CONFIG / REASON_NO_KEY are pinned to the strings the README documents, and disabled_reason is checked to take those constants' values.
  • test_report_does_not_raise_for_tags_that_are_not_a_mapping — a list or int passed as tags is confirmed to be dropped and logged at DEBUG ([trace] could not queue <name>), never raised.

Test plan

  • python -m unittest -v locally on Python 3.8.10: Ran 54 tests ... OK (50 before).
  • The two drift tests were mutation-checked: with pyproject.toml bumped to 0.4.2 and INSTALL_TAG removed from __all__, both failed; both files were restored afterwards.
  • CI test (3.8), test (3.10), test (3.12) green.

Java parity

No Java-visible behavior changed — tests only.

Deferred

No tracking issue — gap found during triage.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

…on-mapping tags

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (head of trace/test-public-surface, CI run 39114246539):

  • Scope: PASS — git diff --stat origin/main shows only tests/test_trace_client.py (+48), all four new tests plus the re/types imports they use.
  • Tests-new: PASS (n/a) — no new public method or attribute; the cycle adds tests only.
  • Tests-fix: PASS (n/a) — no bug fix. In its place the two drift guards were mutation-checked: pyproject.toml bumped to 0.4.2 → version test FAILED (['0.4.1'] != ['0.4.2']); INSTALL_TAG removed from __all__ → exports test FAILED; both restored, suite back to Ran 54 tests ... OK.
  • Sibling structure: PASS — tests sit in the single TraceClientTest class, use long test_<behavior> names, mock.patch.dict for the environment, self.log for log assertions, and close() every enabled client.
  • Sibling renames: PASS (n/a) — nothing renamed.
  • Docs: PASS — no behavior changed; README "Building" (python -m unittest -v, 3.8/3.10/3.12) still matches build.yml.
  • Issue resolution: PASS (n/a) — no Closes; The version tag is added even when it pushes an event past MAX_TAGS #16 deferred with its reason in the PR body.
  • CI: PASS — test (3.8), test (3.10), test (3.12) all green.
  • Stdlib-only: PASS — the only new imports are re and types; pyproject.toml untouched.
  • Py3.8 floor: PASS — test (3.8) green; no post-3.8 syntax added.
  • Never-raises / never-blocks, Log level: PASS (n/a) — no production code touched.
  • Version agreement: PASS — the new test now enforces four of the five places mechanically (the fifth is test_user_agent_names_the_client_version itself).
  • Exports: PASS — enforced mechanically by the new exports test.
  • Java parity noted: PASS — PR body states no Java-visible behavior changed.

Judgment notes (non-blocking):

  • tests/test_trace_client.py:282 — the header assertion hardcodes the repository URL; that is intended, since the header is meant to stay verbatim when vendoring, but a repo rename will need this line updated along with the headers.
  • tests/test_trace_client.py:295 — the public-name heuristic counts module-level names whose __module__ is this module (or that have none, like the str/int constants); a public name re-bound from another module would be skipped. No such name exists today.
  • The version test reads files relative to the test file, so it assumes a source checkout — true for CI and for the documented python -m unittest -v.

Ready to merge: tests-only, CI green, no do-not-auto-merge path touched.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 915f28a into main Oct 18, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the trace/test-public-surface branch October 18, 2026 09:11
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.

1 participant