Skip to content

Keep inline-snapshot disabled when pytest runs in a terminal - #3634

Merged
maxisbey merged 1 commit into
mainfrom
3544-inline-snapshot-tui-flags
Oct 2, 2026
Merged

maxisbey merged 1 commit into
mainfrom
3544-inline-snapshot-tui-flags

Conversation

@maxisbey

@maxisbey maxisbey commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #3544

What was wrong

Running uv run pytest in a terminal outside CI fails 14 tests in tests/client/test_client.py and 39 in the whole suite, all with AttributeError: '...Result' object has no attribute '_meta'.

This is not specific to Windows. It happens on Linux and macOS too, in any terminal where no CI variable is set (Python 3.11 and later; 3.10 passes).

pyproject.toml sets default-flags = ["disable"] for inline-snapshot, but that key only applies when stdout is not a terminal. In a terminal the plugin reads default-flags-tui, which was unset, so it used its own default of create,review and stayed active. When active, the locked version (0.28.0) looks up each keyword of a snapshot(...) literal as an attribute, and _meta is a field alias rather than an attribute. CI and piped runs never see it because the plugin is off there.

What changes

default-flags-tui is set to ["disable"] as well, so a plain pytest run behaves the same in a terminal, in a pipe and in CI.

Updating snapshots on purpose is unchanged: --inline-snapshot=create and --inline-snapshot=fix still rewrite ordinary snapshots.

What it does not fix

  • An explicit --inline-snapshot= flag other than disable still fails on the _meta= snapshots under the locked plugin version. That was already the case and needs a plugin upgrade, which is not part of this change.
  • The implicit create / review behaviour in a terminal goes away. A new empty snapshot() now fails with "run pytest with --inline-snapshot=create" instead of being filled in, and a stale snapshot is an ordinary assertion failure instead of a y/n prompt at the end of the run. Piped runs already behaved this way.

Why there is no regression test

The plugin switches itself off when CI is set, so a test for this would pass in CI with or without the fix.

How it was checked

All runs had the CI variables unset, and the terminal runs confirmed sys.stdout.isatty() is true in the pytest process.

Run (Linux, Python 3.14) Before After
tests/client/test_client.py, piped 47 passed 47 passed
tests/client/test_client.py, pseudo-terminal 14 failed, 33 passed 47 passed
Whole suite, pseudo-terminal 39 failed, 6043 passed 6082 passed
--inline-snapshot=create and fix on a scratch test file updated file updated

The same before and after (14 failures to none, 39 to none) was seen on GitHub-hosted Windows, Ubuntu and macOS runners under a pseudo-terminal.

ruff, pyright and ./scripts/test pass.

AI Disclaimer

`default-flags = ["disable"]` only covers runs whose stdout is not a
terminal. In a terminal outside CI the plugin fell back to its own
`default-flags-tui` default (`create`, `review`), stayed active, and the
locked version raised `AttributeError: ... has no attribute '_meta'` on
every `snapshot(...)` literal that spells the field as `_meta=`.

Set `default-flags-tui` to `disable` as well, so a plain `pytest` run
behaves the same in a terminal, in a pipe and in CI. Snapshots are still
updated with an explicit `--inline-snapshot=create` or `fix`.

Fixes #3544
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

📚 Documentation preview

Preview https://pr-3634.mcp-python-docs.pages.dev
Deployment https://8fa1bc38.mcp-python-docs.pages.dev
Commit d31c9ec
Triggered by @maxisbey
Updated 2026-10-02 21:11:24 UTC

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 1 file

Re-trigger cubic

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, straightforward test-tooling config change.

What was reviewed: the one-line addition of default-flags-tui = ["disable"] under [tool.inline-snapshot] in pyproject.toml, which only affects how the pytest plugin behaves in an interactive terminal; it has no runtime or packaging effect. Checked the lowest-direct CI matrix concern: CI sets CI, which switches the plugin off regardless, and inline-snapshot reads config keys with .get(), so an unrecognised key would be ignored rather than error. The ruled-out candidate (this hides the _meta AttributeError rather than fixing it) is accurate but already stated in the PR description's "What it does not fix" section and is a plugin-version concern outside this change's scope.

Extended reasoning...

The change touches only the [tool.inline-snapshot] table in pyproject.toml, adding a second disable flag so the pytest plugin stays off when stdout is a TTY, matching the existing non-TTY and CI behaviour. It touches no source, tests, lockfile, dependency bounds, or security-sensitive surface. There is no CODEOWNERS file in the repo, the bug hunt ran dry, and the timeline shows no third-party objections. The only investigated candidate (masking rather than fixing the _meta snapshot incompatibility) is openly acknowledged in the PR description and does not make the change incorrect.

@maxisbey
maxisbey merged commit d5cebd1 into main Oct 2, 2026
40 checks passed
@maxisbey
maxisbey deleted the 3544-inline-snapshot-tui-flags branch October 2, 2026 21:17
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.

tests/client/test_client.py: 14 failures on Windows — AttributeError: '...Result' object has no attribute '_meta'

1 participant