Title: Keep inline-snapshot disabled when pytest runs in a terminal by maxisbey · Pull Request #3634 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Keep inline-snapshot disabled when pytest runs in a terminal by maxisbey · Pull Request #3634 · modelcontextprotocol/python-sdk
X Title: Keep inline-snapshot disabled when pytest runs in a terminal by maxisbey · Pull Request #3634 · modelcontextprotocol/python-sdk
Description: 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
Open Graph Description: 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' objec...
X Description: 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...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3634
X: @github
Domain: redirect.github.com
IPv4 address: 140.82.114.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:a058fa48-23cf-362c-5710-236bd5923eb7 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8ACE:25C00B:2F43948:3E03133:6B056EE2 |
| html-safe-nonce | b6b8f78d3bac4905295bcf89dc7d9054fca7efd18c9dd157e4f1c7ef31a91fbe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUNFOjI1QzAwQjoyRjQzOTQ4OjNFMDMxMzM6NkIwNTZFRTIiLCJ2aXNpdG9yX2lkIjoiNzU1NTgyMjE0NTI3MjkwMTM0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6e67503b4215bad9cd9adf052be806453ec87c53e1e809b41e21c9462f0c6bc7 |
| hovercard-subject-tag | pull_request:4721503444 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/3634/files |
| twitter:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| og:image:alt | 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' objec... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b4256ac5f3e310e7945ef5b71c9cb9e264357b1eb20e91d369ed6502a4c486c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f089e689ad324655ac44bf6cdbc04d976105b374 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width