- uv is now only used during test time if you run the inline-snapshot tests with
pytest --use-uv
This solves a problem if you want to package inline-snapshot in distributions (#165)
- Support for a new
storage-dir
configuration option, to tell inline-snapshot where to store data files such as external snapshots.
-
pydantic v1 is supported again. pydantic v1 & v2 create now the same snapshots. You can use
.dict()
to get the same snapshots like in inline-snapshot-0.15.0 for pydantic v1.class M(BaseModel): name: str def test_pydantic(): m = M(name="Tom") assert m == snapshot(M(name="Tom")) assert m.dict() == snapshot({"name": "Tom"})
-
Find
pyproject.toml
file in parent directories, not just next to the Pytest configuration file.
- Code generation for sets is now deterministic.
def test(): assert {1j, 2j, 1, 2, 3} == snapshot({1, 1j, 2, 2j, 3})
-
attrs can now contain unmanaged values
import datetime as dt import uuid import attrs from dirty_equals import IsDatetime from inline_snapshot import Is, snapshot @attrs.define class Attrs: ts: dt.datetime id: uuid.UUID def test(): id = uuid.uuid4() assert Attrs(dt.datetime.now(), id) == snapshot( Attrs(ts=IsDatetime(), id=Is(id)) )
inline_snapshot.extra.warns
to captures warnings and compares them against expected warnings.def test_warns(): with warns(snapshot([(8, "UserWarning: some problem")]), include_line=True): warn("some problem")
- solved a bug caused by a variable inside a snapshot (#148)
-
snapshots inside snapshots are now supported.
assert get_schema() == snapshot( [ { "name": "var_1", "type": snapshot("int") if version < 2 else snapshot("string"), } ] )
-
runtime values can now be part of snapshots.
from inline_snapshot import snapshot, Is current_version = "1.5" assert request() == snapshot( {"data": "page data", "version": Is(current_version)} )
-
f-strings can now also be used within snapshots, but are currently not fixed by inline-snapshot.
- dirty-equals expressions are now treated like runtime values or snapshots within snapshots and are not modified by inline-snapshot.
-
inline-snapshot checks now if the given command line flags (
--inline-snapshot=...
) are valid -
Example(...).run_pytest(raise=snapshot(...))
uses now the flags from the current run and not the flags from the Example.
- do not crash when handling raw f-strings (
rf""
,RF""
,...) (#143)
-
Don't crash for snapshots like
snapshot(f"")
(#139) It first appeared with pytest-8.3.4, but already existed before for cpython-3.11. f-strings in snapshots are currently not official supported, but they should not lead to crashes. -
skip formatting if black returns an error (#138)
- removed the
"Programming Language :: Python :: Implementation :: PyPy"
classifier which was incorrect, because inline-snapshot can not fix snapshots on pypy. inline-snapshot now enforces--inline-snapshot=disable
when used with an implementation other than cpython, which allows it to be used in packages that want to support pypy.
- command line shortcuts can be defined to simplify your workflows.
--review
and--fix
are defined by default. See the documentation for details.
--inline-snapshot=create/fix/trim/update
will no longer show reports for other categories. You can use--inline-snapshot=create,report
if you want to use the old behaviour.
- use tomli instead of toml (#130)
- removed non-optional dirty-equals dependency (#118)
- star-expressions in list or dicts where never valid and cause a warning now.
other=[2] assert [5,2]==snapshot([5,*other])
-
A snapshot which contains an dirty-equals expression can now be compared multiple times.
def test_something(): greeting = "hello" for name in ["alex", "bob"]: assert (name, greeting) == snapshot((IsString(), "hello"))
- Use tomllib instead of PyPI toml on Python 3.11 and later
- added extra.prints
- 3.13 support
- strings with one line-break at the end become no multiline strings
- add license to project metadata and some other fixes in pyproject.toml (#104)
- implement extra.raises
- added inline_snapshot.testing.Example which can be used to test 3rd-party extensions
- check if the result of copy.deepcopy() is equal to the copied value
- support for
enum.Enum
,enum.Flag
,type
and omitting of default values (#73)
- changed how --inline-snapshot=disable works in combination with xdist (#90)
- fix typo, rename 'theme' with 'them'
- trigger no update for trailing comma changes
- removed support for python 3.7
- removed
--inline-snapshot-disable
option and replaced it with--inline-snapshot=disable
- new flags: disable, short-report, report and review
- added config option and environment variable to specify default flags
- show diff of changed snapshots in pytest report
- interactive review mode
- check if inline-snapshot is used in combination with xdist and notify the user that this is not possible
- change the quoting of strings does not trigger an update
- removed restriction that the snapshot functions has to be called snapshot (#72)
- report error in tear down for sub-snapshots with missing values (#70)
- element access in sub-snapshots does not create new values
- make typing less strict
- prevent dirty-equal values from triggering of updates
- fix lists by calculating the alignment of the changed values
- insert dict items
- delete dict items
- preserve not changed dict-values and list-elements
- update with UndecidedValue
- handle dicts with mulitple insertions and deletions
- handle lists with mulitple insertions and deletions
- fixed typing and coverage
- removed old needs* logic
- removed get_result
- use _get_changes api for DictValue
- use _get_changes api for CollectionValue
- use _get_changes api for MinMaxValue
- use _get_changes
- moved some functions
- removed old --update-snapshots option
- use utf-8 encoding to read and write source files
- store snapshot values in external files
- remove upper bound from dependencies in pyproject.toml
- show better error messages
- support 3.12
- do not change empty snapshot if it is not used
- escaped linebreak at the start/end of multiline strings
- added py.typed
- handle update flag in sub-snapshots correctly
- fixed some edge cases where sub-snapshots had problems with some flags
- string literal concatenation should trigger no update
- added
__all__
to inline_snapshot - flags fix/trim/create/update are changing the matching snapshots
- values have to be copyable with
copy.deepcopy
- snapshot the current value of mutable objects
l = [1] assert l == snapshot([1]) # old behaviour: snapshot([1, 2]) l.append(2) assert l == snapshot([1, 2])
- black configuration files are respected
-
value <= snapshot()
to ensure that something gets smaller/larger over time (number of iterations of an algorithm you want to optimize for example), -
value in snapshot()
to check if your value is in a known set of values, -
snapshot()[key]
to generate new sub-snapshots on demand. -
convert strings with newlines to triple quoted strings
assert "a\nb\n" == snapshot( """a b """ )
-
preserve black formatting
- updated executing
- fixed typo in pytest plugin name
- first inline-snapshot version