Skip to content

Releases: approvals/ApprovalTests.Python

deserialize_json_fields

19 Sep 17:58
Compare
Choose a tag to compare

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

22 Aug 17:46
Compare
Choose a tag to compare

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

18 Jul 17:59
Compare
Choose a tag to compare

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

27 Jun 18:13
Compare
Choose a tag to compare

A bug with the namer was introduced which is now fixed. No other changes

Standardized line endings at end of files

13 Jun 17:06
Compare
Choose a tag to compare

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

23 May 17:44
Compare
Choose a tag to compare

You can now set the approval file extensions via options:
Options().for_file.with_extension(".md")

Date scrubbers and verify(Any)

16 May 17:28
Compare
Choose a tag to compare

Date scrubbers are quite basic and only work with json-fied datetimes
Verify now converts its input to string before verifying

Scrubbers

09 May 17:41
Compare
Choose a tag to compare

You can now scrub your approval files

Options

02 May 17:20
Compare
Choose a tag to compare

The reporter can now be passed into any verify call via options.

more to come later.

Easier to understand error messages

18 Apr 18:00
Compare
Choose a tag to compare