Skip to content
Become a
Sponsor or follow @15r10nk on
or
for updates

# `` `get_snapshot_value(snapshot_value, which='new')`

Extracts and returns the raw value stored inside a snapshot, removing all inline-snapshot-specific wrappers such as those generated by `external()`, `Is()`, or `snapshot()`.

This function is primarily intended for extension authors who need direct access to the value of a previously stored snapshot. For standard test assertions, prefer using the snapshot directly.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`snapshot_value` | `Snapshot[T]` | The snapshot object from which to extract the value. | required

`which`

`Literal['new', 'old']`

can be:

- `"old"`: the value which is "visible" in the source is returned
- `"new"`: the current value is returned

`'new'`

Returns: The unwrapped value contained in the snapshot.

Example

    from inline_snapshot import external, snapshot, get_snapshot_value

    s = snapshot([0, external("uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.json")])

    if record:
        # Store value
        assert s == [0, 5]
    else:
        # Use value from snapshot
        value = get_snapshot_value(s)
        # ... do something with value