Releases: approvals/ApprovalTests.Python
Parse for Inline Approvals
Utilities to make it much easier to rapidly develop tests
Read the How To
Bugfixes with inline approvals and whitespace
Fixed a bug with inline approvals where the input could not have preceding whitespace
inline approvals bug fixes
- options.inline can now be created outside of the test method
- renamed
quiet_reporter
toreport_quietly
- kept link to old name for backwards compatibility
- fixed bug in
quiet_reporter
andInlineReporter
where they were throwing the wrong exception on failure
inline approvals works with unittest
fixed a bug where inline was working with pytest but not unittest
verify_all_combinations_with_labeled_inputs
You can now do this:
def test_with_labeled_input(self) -> None:
verify_all_combinations_with_labeled_input(
lambda a,b: a+b+1,
arg1=(1, 3),
arg2=(2, 4),
)
and it will produce:
(arg1: 1, arg2: 2) => 4
(arg1: 1, arg2: 4) => 6
(arg1: 3, arg2: 2) => 6
(arg1: 3, arg2: 4) => 8
verify_all(header=none)
Breaking Change
verify_all with an empty head will no longer add 2 blank lines at the beginning of the file
Parse Inputs from docstring
This allows for inline approvals to get the inputs from the approved docstring.
(more coming soon)
Here's an example where the inputs (a,b,c) are gathered from the docstring:
from approvaltests.inline.parse_docstring import parse_docstring
def test_uppercase():
"""
a -> A
b -> B
c -> C
"""
verify("\n".join([ f"{a} -> {a.upper()}" for a in parse_docstring()]), options=Options().inline())
support alternative naming patterns in pytest
Fixes #155
by default pytest requires your functions to start with test_
this is configurable in pytest was not supported by Approval Tests
it is now supported in Approval Tests
Inline Reporter handle single and double quotes
. d for future Co-Authored-By: 4dsherwood <[email protected]> Co-Authored-By: Michael R Wolf <[email protected]> Co-Authored-By: Susan Fung <[email protected]> Co-Authored-By: Nitsan Avni <[email protected]>
Inline Approvals
You can now use inline approvals by adding
verify(result, options=Options().inline())
This will use the test method docstring as the expected result instead of a separate .approved.txt
file.
The current reporter has limited support for Python, it will be improved.