Approvaltests

Latest version: v14.2.0

Safety actively analyzes 681866 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 18

10.1.0

You can now use inline approvals by adding

python
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.

10.0.0

ApprovalTests only wants one call to verify() per test.
There are ways to go around this but if you call verify where it would want the exact same file name twice, it will now throw an exception.
This will make it easier for people to not be confused as most other testing frameworks allow you to put multiple assertions in the same test.

Backwards compatibility
There are some situations where you want to check that two different processes produce the same result.
Calling verify multiple times in the same test can be a way to do this.
If you want to do that, we have provided the following:

`approvals.settings().allow_multiple_verify_calls_for_this_method()`

9.0.0

`verify_as_json()` creates `.json` files instead of `.txt`

This is a **BREAKING CHANGE**.

There are two ways to fix this.

1. re-approve the `.json` files

Either:

1. Rename the `.txt` files to `.json`
2. Move them over in your diff tool
3. Use `ReporterThatAutomaticallyApproves`
`verify_as_json(result, options=Options().with_reporter(ReporterThatAutomaticallyApproves()))`
5. Use `ReporterByCopyMoveCommandForEverythingToClipboard` + paste into your terminal
`verify_as_json(result, options=Options().with_reporter(ReporterByCopyMoveCommandForEverythingToClipboard()))`

2. Keep your `.txt` files backwards compatible

python
verify_as_json(result, options=Options().for_file.with_extension(".txt"))

8.4.1

Allows for easy testing of the standard python logging library.

py
def test_basic_logging():
with verify_logging():
logging.info("1")
logging.info(datetime.now())


Also, small bug fix where scrubbers where being replaced instead of added to

8.4.0

Allows for easy testing of the standard python logging library.

py
def test_basic_logging():
with verify_logging():
logging.info("1")
logging.info(datetime.now())

8.3.1

Added executable commands, plus fixed bugs with import statements

Page 4 of 18

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.