inline-snapshot

create and update inline snapshots in your python tests

MIT License

Downloads
189.5K
Stars
326
Committers
5

Bot releases are hidden (Show)

inline-snapshot - v0.11.0 Latest Release

Published by 15r10nk 3 months ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.10.2...v0.11.0

inline-snapshot - v0.10.2

Published by 15r10nk 5 months ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.10.1...v0.10.2

inline-snapshot - v0.10.1

Published by 15r10nk 5 months ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.10.0...v0.10.1

inline-snapshot - v0.10.0

Published by 15r10nk 5 months ago

What's Changed

BREAKING CHANGE

  • removed support for python 3.7
  • removed --inline-snapshot-disable option and replaced it with --inline-snapshot=disable

Feat

  • 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
  • docs: Explain where the external files are saved by @pawamoy in https://github.com/15r10nk/inline-snapshot/pull/74

New Contributors

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.9.0...v0.10.0

inline-snapshot - v0.9.0

Published by 15r10nk 5 months ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.8.2...v0.9.0

inline-snapshot - v0.8.2

Published by 15r10nk 6 months ago

What's Changed

  • removed restriction that the snapshot functions has to be called snapshot (#72)
    which allows you to use
    from inline_snapshot import snapshot as snap
    
  • report error in tear down for sub-snapshots with missing values (#70)
  • element access in sub-snapshots does not create new values

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.8.1...v0.8.2

inline-snapshot - v0.8.1

Published by 15r10nk 6 months ago

What's Changed

fixed problems with the typing of the following snapshots:

snapshot([])
snapshot({})

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.8.0...v0.8.1

inline-snapshot - v0.8.0

Published by 15r10nk 6 months ago

What's Changed

Snapshot parts can now be replaced by dirty-equals expressions. These parts will not be changed if the user uses --inline-snapshot=fix. This should provide more flexibility if snapshots change frequently for unimportant reasons.

from inline_snapshot import snapshot
from dirty_equals import IsDatetime
import datetime

def get_data():
    return {
        "date": datetime.datetime.utcnow(),
        "payload": "some data",
    }

def test_function():
    assert get_data() == snapshot(
        {
            "date": IsDatetime(),
            "payload": "some data",
        }
    )

Documentation

Thank you to @alexmojaki for the Idea.

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.7.0...v0.8.0

inline-snapshot - v0.7.0

Published by 15r10nk 8 months ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.6.1...v0.7.0

inline-snapshot - v0.6.1

Published by 15r10nk 9 months ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.6.0...v0.6.1

inline-snapshot - v0.6.0

Published by 15r10nk 10 months ago

snapshot values can now be saved in external files:

assert outsource("large string\n" * 1000) == snapshot(external("8bf10bdf2c30*.txt"))

see the documentation for more details

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.5.2...v0.6.0

inline-snapshot - v0.5.2

Published by 15r10nk 11 months ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.5.1...v0.5.2

inline-snapshot - v0.5.1

Published by 15r10nk 12 months ago

show the user better error messages when he mixes snapshot operations.

def test_something():
    s = snapshot(5)
    assert 5 <= s
    assert 5 == s
>    assert 5 == s
E    TypeError: This snapshot cannot be use with `==`, because it was previously used with `x <= snapshot`

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.5.0...v0.5.1

inline-snapshot - v0.5.0

Published by 15r10nk about 1 year ago

What's Changed

  • fix: do not change an empty snapshot if it is not used
  • 3.12 support

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.4.0...v0.5.0

inline-snapshot - v0.4.0

Published by 15r10nk about 1 year ago

Escaped newlines for multiline strings

Multiline strings are now formatted so that the quotes are always on a separate line.

def test_something():
    assert "\nfirst line\nsecond line" == snapshot(
        """\

first line
second line\
"""
    )

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.3.2...v0.4.0

inline-snapshot - v0.3.2

Published by 15r10nk about 1 year ago

correct handling of flags for sub-snapshots:

from inline_snapshot import snapshot

def test_foo():
    s = snapshot(
        {
            "hello": "world",
            "number": 8,
            "values": ["old value"],          # trim: remove "old value"
        }
    )
    assert "mars" == s["hello"]               # fix:    change "world" to "mars"
    assert 5 <= s["number"]                   # trim:   change 8 to 5
    assert "some output" in s["known output"] # create: add "known output": ["some output"]
    assert "new value" in s["values"]         # fix:    add "new value"

pytest --inline-snapshot=create|fix|trim will apply the changes to the snapshot

every flag implies --inline-snapshot=update

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.3.1...v0.3.2

inline-snapshot - v0.3.1

Published by 15r10nk over 1 year ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.3.0...v0.3.1

inline-snapshot - v0.3.0

Published by 15r10nk over 1 year ago

What's Changed

BREAKING CHANGE

  • values have to be copyable with copy.deepcopy

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.2.1...v0.3.0

inline-snapshot - v0.2.1

Published by 15r10nk over 1 year ago

What's Changed

Full Changelog: https://github.com/15r10nk/inline-snapshot/compare/v0.2.0...v0.2.1

inline-snapshot - v0.2.0

Published by 15r10nk over 1 year ago

support for new snapshot operations:

  • 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.

new features:

  • convert strings with newlines to triple quoted strings
  • preserve black formatting

more information can be found in the new documentation