Releases: 15r10nk/inline-snapshot
0.34.1
0.34.0
0.33.0
Added
-
snapshot_arg(), which lets you movesnapshot()calls from the call site into the helper function itself. -
Example.format(): new method to format a Python file in the example using Black.
-
Example.is_formatted(): new method to check whether a Python file in the example is already Black-formatted.
Changed
-
Example.run_inline: exception strings in
raisesare now formatted the same wayinline_snapshot.extra.raisesdoes, which is shorter for small assertions likeraises=snapshot("UsageError: default value cannot be a Custom value"). -
Example.run_inline: the
raises,stderr, andchanged_filesarguments are now handled withsnapshot_arg(), sosnapshot()is no longer needed at the call site.raisesdefaults to"<no exception>"andchanged_filesdefaults to{}. -
Example.run_inline: the
reported_categoriesargument is now handled withsnapshot_arg()and its type changed fromlist[Category]toset[Category]. It is now only asserted when the reported categories differ from the CLI flags passed viaargs. -
Example.run_pytest: the
returncode,error,stderr,changed_files, andoutcomesarguments are now handled withsnapshot_arg(), sosnapshot()is no longer needed at the call site.returncodedefaults to0,changed_filesdefaults to{}, andoutcomesdefaults to{"passed": 1}. -
Example.run_pytest: the
errorassertion is now only performed on Python ≥ 3.11. -
Example.run_pytest: stdout and stderr are now printed as Rich panels instead of plain text.
-
extra.raises: the
exceptionargument is now handled withsnapshot_arg(), sosnapshot()is no longer needed at the call site. -
extra.prints: the
stdoutandstderrarguments are now handled withsnapshot_arg(), sosnapshot()is no longer needed at the call site. -
extra.warns: the
expected_warningsargument is now handled withsnapshot_arg(), sosnapshot()is no longer needed at the call site. -
extra.Transformed and extra.transformation: the
valueargument is now handled withsnapshot_arg().
Fixed
- Fixed
repr(external_file(...))to use a path relative to the calling file instead of the absolute path, which also fixes incorrect reprs on Windows.
0.32.7
Fixed
- Fixed snapshot comparison for dicts where keys are dataclass instances (or other custom objects used as dict keys), which previously caused corrupted snapshots — either collapsing multiple entries into one or appending duplicate keys on subsequent runs (#363).
- Fixed tuple snapshot updates to compare elements positionally rather than using sequence alignment, so existing expressions (e.g.
3 + 3) are preserved when elements are removed from or added to a tuple.
0.32.6
Fixed
- Pydantic models, attrs and dataclasses with
NewType-typed fields now generate correct snapshots that wrap the field value with theNewTypeconstructor (e.g.Something(some_id=SomeID(1))instead ofSomething(some_id=1)). This could only be fixed for Python >= 3.10.
0.32.5
0.32.4
Added
- Added
context_managersparameter toExample.run_inline(), allowing tests to inject context managers (e.g.unittest.mock.patch) that are active duringshow_report().
Fixed
- Fixed
UsageError("unmanaged values can not be compared with snapshots")raised during session teardown when using-kto filter tests (#355). This was caused by inline-snapshot trying to update snapshots that were never compared. This is a rare edge case that caused problems when matchers were used, so it has been removed.
0.32.3
Changed
- Improved performance of
snapshot()by using lazy evaluation.
Fixed
- Fixed code generation for Call objects created with
builder.create_call(). - use the handler for datetime types only for the concrete types and not the subclasses.
0.32.2
0.32.1
Fixed
-
Fixed handling of
datetimeandtimeobjects with timezone information. Thetzinfoparameter is now properly included in snapshots, andtimezone.utcis represented with the correct import (from datetime import timezone). -
Fixed customize hook registration to properly check if objects are functions before inspecting the
inline_snapshot_implattribute, preventing potential attribute errors when scanning conftest modules.