Skip to content

customize snapshot_path #335

@15r10nk

Description

@15r10nk

add more arguments to the customize hook which give the user some information about the location in the snapshot, which is useful in cases like this:

from inline_snapshot import snapshot

def request(user):
    return {"user":user,"age": len(user)*2}

def test():
    user="Tom"    
    assert request(user) == snapshot({"user":user,"age":6})

where the key of the dict entry can be used to find the correct variable.

def customize(value, snapshot_path):
    ...

snapshot_path is a list of locations in the snapshot in this case [DictValue(key="user")], but in can contain other entries like ListIndex or CallArgument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions