By default, inline-snapshot manages everything inside snapshot(...). However, you can use "unmanaged" types that the library will ignore and refuse to update or fix, even if they cause tests to fail. This is useful for parts of the snapshot you want to control manually.
Unmanaged types include:
dirty-equals expressions- Dynamic code inside
Is(...) - Snapshots nested inside other snapshots
- f-strings
You can also define your own unmanaged types using the @declare_unmanaged decorator. Unmanaged types must be placed within supported containers like list, tuple, dict, namedtuple, dataclass, or attrs to be handled correctly.
from inline_snapshot import declare_unmanaged, snapshot
@declare_unmanaged
class AllEqual:
def __init__(self, value):
self.value = value
def __eq__(self, other):
return all(o == self.value for o in other)
def test_all_equal():
# AllEqual is unmanaged, but the snapshot(1) inside it is managed
assert {"text": "hello", "values": [1, 1, 1]} == snapshot(
{"text": "hello", "values": AllEqual(snapshot(1))}
)