Releases: approvals/ApprovalTests.Python
deserialize_json_fields
verify_as_json
can now take an optional parameter deserialize_json_fields
which if True will produce nicer formatted output.
{
"type": "dictionary",
"value": "{\"a\": 1, \"b\": 2, \"c\": 3}"
}
vs
{
"type": "dictionary",
"value": {
"a": 1,
"b": 2,
"c": 3
}
}
Create Regex Scrubber
Create regex scrubber
Renamed scrub_with_regex
to create_regex_scrubber
.
It can now take either a str
or a Callable[[int], str]
Going forward, functions that return scrubber will start with create
while functions that scrub directly will start with scrub
Storyboards
Why Use Storyboards
Sometimes we might want to see different steps in a workflow or lifetime of an object. Storyboards are a convenience object to help enable that.
Approvaltests allows us to look at a complete object instead of just pieces of it. Storyboards allow us to track an object through time.
The mechanism to map time to space that storyboards use is very analogous to a comic book, but with each frame vertically after each other so that it works well with the diff tool and shows a progression.
How To Use Storyboards
Here is example of creating story board, adding content to it, and verifying it.
story = Storyboard()
story.add_description("Spinning wheel")
story.add_frame(ascii_wheel)
ascii_wheel.advance()
story.add_frame(ascii_wheel)
verify(story)
will produce
Spinning wheel
Initial:
-
Frame #1:
\
Fixed Major bug with unix and python3.8 and above
A bug with the namer was introduced which is now fixed. No other changes
Standardized line endings at end of files
v 1.0.0
Verify(text) ensures a newline at the file
BREAKING CHANGE
Since most tools will ensure a newline at the end of a file, approval test is now
adding this to allow copying approval results in diff tools to work correctly.
Please note that this will break all you previous approvals that do not end with
a newline!
This will show by your diff tool opening with two files that look identical, but
one actually has a newline at the end.
Upgrade Path
We suggest you use ReporterByCopyMoveCommandForEverythingToClipboard()
as your Default Reporter to re-approve all your files.
Namer handles multiple nested methods in a unit test
Previously if you had nested methods in your unit test, the names would incorrectly
identify the help method rather than the test method. This is now fixed.
Options with file extension
You can now set the approval file extensions via options:
Options().for_file.with_extension(".md")
Date scrubbers and verify(Any)
Date scrubbers are quite basic and only work with json-fied datetimes
Verify now converts its input to string before verifying