Skip to content

Releases: approvals/ApprovalTests.Python

InlineOptions.semi_automatic_with_previous_approved()

19 May 19:33
Compare
Choose a tag to compare

Will produce the following doc_string approval:

    """
    42
    ***** DELETE ME TO APPROVE *****
    vvvvv PREVIOUS RESULT vvvvv
    41
    """

Options().add_reporter(r)

12 May 18:22
Compare
Choose a tag to compare

You can now add a reporter and both the previous and the new will launch. This is extra helpful with inline approvals

Inline approvals uses `InlineOptions`

28 Apr 19:49
Compare
Choose a tag to compare

BREAKING CHANGE

verify(result, options=Options().inline(show_code=False))
verify(result, options=Options().inline(show_code=True))

is now

verify(result, options=Options().inline(InlineOptions.show_code(False)))
verify(result, options=Options().inline())

New Features in Inline Approvals

Semi-automatic Workflow

verify(result, options=Options().inline(InlineOptions.semi_automatic()))

In this workflow, the docstring will be automatically updated, but with an extra line to be removed as approval.

Example:

Running this test:

def test_with_semi_automatic_inline_workflow():
    verify("1\n2", options=Options().inline(InlineOptions.semi_automatic()))

Will automatically update the test source file to:

def test_with_semi_automatic_inline_workflow():
   """
   1
   2
   ***** DELETE ME TO APPROVE *****
   """
    verify("1\n2", options=Options().inline(InlineOptions.semi_automatic()))

And as the last line suggests, when it is removed the test will start passing.

Fully Automatic Workflow

With this workflow, the extra line is not added.

def test_with_automatic_inline_workflow():
    verify("1\n2", options=Options().inline(InlineOptions.automatic()))

Becomes:

def test_with_automatic_inline_workflow():
   """
   1
   2
   """
    verify("1\n2", options=Options().inline(InlineOptions.automatic()))

Bug Fixes

Fix #159: would sometimes report approved and received as matching when they weren't. This usually only happened on cyberdojo with inline approvals,

link to approval-utilities

13 Apr 01:12
Compare
Choose a tag to compare
v11.2.1

d updated markdown snippets

Parse for Inline Approvals

07 Apr 18:43
Compare
Choose a tag to compare

Utilities to make it much easier to rapidly develop tests
Read the How To

Bugfixes with inline approvals and whitespace

24 Mar 18:13
Compare
Choose a tag to compare

Fixed a bug with inline approvals where the input could not have preceding whitespace

inline approvals bug fixes

17 Mar 19:34
Compare
Choose a tag to compare
  • options.inline can now be created outside of the test method
  • renamed quiet_reporter to report_quietly
    • kept link to old name for backwards compatibility
  • fixed bug in quiet_reporter and InlineReporter where they were throwing the wrong exception on failure

inline approvals works with unittest

10 Mar 18:33
Compare
Choose a tag to compare

fixed a bug where inline was working with pytest but not unittest

verify_all_combinations_with_labeled_inputs

03 Mar 19:38
Compare
Choose a tag to compare

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)

25 Feb 17:28
Compare
Choose a tag to compare

Breaking Change

verify_all with an empty head will no longer add 2 blank lines at the beginning of the file