Skip to content

test(python): ask the pty REPL cases for JSON, as the rust ones already do - #1030

Merged
thekevinscott merged 3 commits into
mainfrom
claude/1027-repl-e2e-format
Sep 4, 2026
Merged

thekevinscott merged 3 commits into
mainfrom
claude/1027-repl-e2e-format

Conversation

@thekevinbot

@thekevinbot thekevinbot commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Five pty cases in packages/python/tests/e2e/repl_interactive_test.py assert [{"n":41}] and have been red since 060576f taught the CLI to lay rows out as a table when stdout is a terminal.

Fixes #1027

Which side was wrong

The tests. The table is the intended REPL output, and there is direct evidence rather than inference:

  • docs/reference/cli.md ("Output format") states it as the contract: auto (the default) renders "Table if stdout is a terminal, JSON otherwise", and gives the table layout — aligned columns, a rule under the header, a row count — as the documented shape. The docs are neither silent nor contradictory here.
  • 060576f's own message says the rust pty cases were moved onto --format json in that same commit, "on a terminal they would otherwise read rows through a table layout, making every one of them a rendering test as well as a termination test", and that it added "one new case cover[ing] the default they gave up". packages/rust/tests/repl_tty_e2e.rs carries both the --format json sessions and a default_format() case asserting the table.
  • The python suite was simply missed in that pass. It landed 55 minutes before the renderer and E2E does not run in CI, so nothing flagged it.

Manual confirmation of both directions at a real pty:

$ script -qc "target/debug/dirsql 'SELECT 41 AS n'" /dev/null
n
--
41

1 row

$ script -qc "target/debug/dirsql 'SELECT 41 AS n' --format json" /dev/null
[{"n":41}]

So no REPL change. Not a regression, no behavior change, and therefore no red-CI step: this is a stale-assertion repair.

What changed

One line. The open_repl fixture opens the REPL with --format json, matching the rust pty suite. These cases are about the up arrow, the history file, Ctrl+C, and the continuation prompt; none has an opinion about layout, and the table default stays covered by packages/rust/tests/repl_tty_e2e.rs.

The alternative — rewriting five assertions against the table — was rejected as both larger and weaker: the rendered 41 sits on a screen that still shows the typed SELECT 41 AS n;, so a text match on the cell would pass for the wrong reason.

One line of comment rides along, because the reason a history test pins JSON is not derivable from the line and a future reader could plausibly delete it and re-break the suite:

# A tty gets a table; JSON keeps these cases on rows, not layout.

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: pass
  • TypeScript SDK e2e: N/A — no TS change
  • Rust core e2e (if applicable): N/A — no rust change
  • packages/python/e2e-attestations/<branch>.json receipt written if packages/python changed (just e2e-attest-python) — not owed, see below
  • packages/ts/e2e-attestations/<branch>.json receipt written if packages/ts changed (just e2e-attest-ts) — N/A
  • Command(s) run: cargo build -p dirsql --features cli, uv run maturin develop, just test-e2e
  • Result summary: 37 passed in 12.98s (exit 0). Before the change: 5 failed, the exact five named in REPL e2e tests still assert JSON output after table rendering landed #1027.

No receipt: the python-sdk job scopes e2e-verify to source: packages/python/dirsql plus [e2e].extra_scope = ["packages/rust/src", "packages/python/src"]. This diff touches only packages/python/tests/e2e/, so the gate owes nothing. (Also noting the local testing-conventions on PATH is 0.0.85, well behind the 0.0.111 CI uses — not exercised here, but relevant to anyone who does need a receipt.)

Changelog / Migrations

  • Changelog fragment — not required. changelog_gate/decide.py excludes anything under a package's tests/ directory from "non-test source", and this diff is one test file.
  • Migration fragment — not required; no API or runtime behavior change.

PARITY.md untouched: no SDK public API changed.

CI

The only failure this branch ever had was the shared python-sdk / Static checks (python) red that hit main and every open PR when testing-conventions 0.0.111 (moving @v0) added unit one-function-per-file and integration lint's no-first-party-patch. #1023 fixed both and has merged; origin/main is merged in here (clean, no conflicts) and the branch carries no defect of its own.

Verified locally on the merged tree with just preflight --gate one-function-per-file --gate integration-lint --gate unit-lint --gate colocated-test against testing-conventions 0.0.111: 0 failing pairs. The new max_lines = 100 rule cannot bite this diff — it scans packages/python/dirsql, and the diff is one file under packages/python/tests/e2e/.

python-sdk / E2E attestation freshness (e2e verify) passes, confirming no receipt is owed for this diff.

…dy do

Five cases in `repl_interactive_test.py` assert `[{"n":41}]` and have been
red since `060576f` taught the CLI to lay rows out as a table when stdout is
a terminal. The tests landed 55 minutes earlier and were never revisited.

The table is the intended output, not a regression: `docs/reference/cli.md`
documents `auto` as "table if stdout is a terminal, JSON otherwise", and
`060576f` moved the rust pty cases onto `--format json` for exactly this
reason -- on a terminal they would otherwise be rendering tests as well as
editor tests. It added a separate case for the default it gave up. The
python suite was simply missed in that pass.

So the fix is the same one: the fixture opens the REPL with `--format json`.
These cases are about the up arrow, the history file, `Ctrl+C`, and the
continuation prompt; none of them has an opinion about layout, and the table
default stays covered by `packages/rust/tests/repl_tty_e2e.rs`.

This unblocks `just e2e-attest-python`, which runs the whole suite and needs
exit 0 to write a receipt.
`--format json` on a history test reads as cruft, and deleting it puts the
five cases straight back on the table layout they have no opinion about.
@thekevinscott
thekevinscott merged commit 8a527c3 into main Sep 4, 2026
38 checks passed
@thekevinscott
thekevinscott deleted the claude/1027-repl-e2e-format branch September 4, 2026 20:49
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.

REPL e2e tests still assert JSON output after table rendering landed

2 participants