New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate assert_display_snapshot
, refactor macros
#385
Conversation
This PR: - Deprecates `assert_display_snapshot` in favor of `assert_snapshot`, as discussed in mitsuhiko#379 - Makes a sizable change in how macros are constructed: - It makes macros consistent — previously `debug` & `display` had different forms than the others, not taking a `debug_expr`. - The non-redaction macros are a simple wrapper of `_assert_snapshot_base`, which takes a closure `transform` of how to transform the input to a string. - The redaction macros are a simple wrapper of `_assert_serialized_snapshot`, which takes an arg `format` (similar to before), and uses that to construct a transform. - As a result, the boilerplate for each macros is removed. It's not quite complete, but wanted to post before spending more time on it. Still todo: - We get a couple of test failures; I need to look into this; we seem to be generating an additional `---` in some yaml snapshots. (possibly something is being converted to string twice?) - Update docs; previously the debug_expr wasn't documented, and now that the source is more opaque this is more important
This is updated, with all the tests passing, and better comments around the macros. One thing that would make the code even simpler — serializing values the same for |
aae36e0
to
da4ea86
Compare
Relies on mitsuhiko/insta#385; otherwise not all snapshot macros implement all of these
Relies on mitsuhiko/insta#385; otherwise not all snapshot macros implement all of these
Updated the docs at mitsuhiko/insta-website#17 |
I will try to get this reviewed this week. |
* Enumerate all the snapshot types Relies on mitsuhiko/insta#385; otherwise not all snapshot macros implement all of these * Add debug expr to docs
@mitsuhiko the gentlest of pings! Also will take feedback if you think it's not so great :) |
I am in favor of this. I will try to get it merged and released ahead of backwards incompatible changes. |
Thanks! |
Just a heads up, @mitsuhiko + @max-sixty - I have good reason to believe that these changes broke one of our tests. It seems like this version of the |
I'll take a look, thanks @kennethloeffler ! |
This is fixed in #453, apologies for the temporary break |
It's perfectly okay - it's easy to see how this flew under the radar 😅 |
Sorry for that. I pushed out a fix! |
This PR:
assert_display_snapshot
in favor ofassert_snapshot
, as discussed inassert_display_snapshot
vs.assert_snapshot
#379debug
&display
had different forms than the others, not taking adebug_expr
._assert_snapshot_base
, which takes a closuretransform
of how to transform the input to a string._assert_serialized_snapshot
, which takes an argformat
(similar to before), and uses that to construct a transform.It's not quite complete, but wanted to post before spending more time on it.Now completePrevious todos:
---
in some yaml snapshots. (possibly something is being converted to string twice?)