UsageError("unmanaged values can not be compared with snapshots") when using -k flag #355#356
UsageError("unmanaged values can not be compared with snapshots") when using -k flag #355#356
Conversation
| for change in snapshot._changes(): | ||
| try: | ||
| change_list = list(snapshot._changes()) | ||
| except Exception as exception: |
There was a problem hiding this comment.
To get even more, at least for Python 3.11+ (probably 80-90% of the users by now), you could use https://docs.python.org/3/library/exceptions.html#lib-exception-groups to collect even more details :-)
There was a problem hiding this comment.
but ExceptionGroup is derived from Exception, which means that this code catches already ExceptionGroup. Or am I missing something here?
f012b87 to
aff7421
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves error reporting when collecting snapshot changes (during show_report()), and adds tests to verify the new error output. It also extends the Example.run_inline() helper to support injecting additional context managers (used by the new tests).
Changes:
- Wrap snapshot change collection in
SnapshotSession.show_report()to raise aRuntimeErrorthat includes snapshot expression + file/line. - Extend
Example.run_inline()to accept extracontext_managersfor test-time patching. - Refactor/add tests to validate string-update output and the new change-collection error reporting (including Windows path normalization).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils.py | Adds a reusable path_transform to normalize Windows path separators in snapshots. |
| tests/test_string.py | Refactors string snapshot tests and introduces a helper fixture to reduce duplication. |
| tests/test_change_collection_error.py | Adds coverage for the new error message when _changes() raises during report generation. |
| src/inline_snapshot/testing/_example.py | Adds support for injecting context managers into inline example runs; adjusts exception handling/reporting behavior. |
| src/inline_snapshot/_types.py | Adds typing for _expr on snapshot references. |
| src/inline_snapshot/_snapshot_session.py | Adds error-wrapping around snapshot._changes() to improve diagnostics (file/line + snapshot repr). |
| src/inline_snapshot/_snapshot/undecided_value.py | Removes change-generation logic for undecided values (now yields no changes by default). |
| src/inline_snapshot/_inline_snapshot.py | Adds __repr__ for SnapshotReference and tightens AST typing with cast(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3cfab45 to
f70c0e6
Compare
…) when using -k flag (#355)
Description
Related Issue(s)
Checklist
hatch run cov:github).hatch run changelog:entryfeat:will cause a major andfix:a minor version bump)