Skip to content

Commit

Permalink
d Doco changes
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 29, 2022
1 parent 16482b2 commit ce73ace
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions docs/how_to/create_custom_verify_methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- toc -->
## Contents

* [Custom Verify Method](#custom-verify-method)
* [Create a Custom Verify Method](#create-a-custom-verify-method)
* [Create a `Verifiable` Object](#create-a-verifiable-object)<!-- endToc -->

## Create a Custom Verify Method
Expand All @@ -12,7 +12,24 @@ One method is to create a custom `verify()` method for your particular situation

For example, as we use it to handle json:

snippet: verify_as_json
<!-- snippet: verify_as_json -->
<a id='snippet-verify_as_json'></a>
```py
def verify_as_json(
object,
reporter=None,
*, # enforce keyword arguments - https://www.python.org/dev/peps/pep-3102/
deserialize_json_fields = False,
options: Optional[Options] = None
):
if deserialize_json_fields:
object = approvaltests.utils.deserialize_json_fields(object)
options = initialize_options(options, reporter)
n_ = to_json(object) + "\n"
verify(n_, None, encoding="utf-8", newline="\n", options=options)
```
<sup><a href='/approvaltests/approvals.py#L189-L202' title='Snippet source file'>snippet source</a> | <a href='#snippet-verify_as_json' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## Create a `Verifiable` Object

Expand Down

0 comments on commit ce73ace

Please sign in to comment.