Simple approval testing.
Project description
Unchanged
A simple approvals/snapshot/golden master library that lets you configure your testing tools any way you want.
Features
- Sensible defaults: Just want to do some basic snapshot on most Python objects? Go for it. Snapshot testing should be easy.
- Highly Modular: Want to do fuzzy comparison, pre-check file scrubbing, have the diff display in a non-Python program, and use the latest test runner? No problem, plug your tools and functions into
unchanged
based on your own preferences and project needs. - No External Dependencies:
unchanged
's internals are stupidly simple, using only the Python standard library--you decide what packages your tests will rely on, not us.
Installation
pip install unchanged
Example Usage
from unchanged import verify
Hello world is still "Hello world"
from unchanged import verify
verify("Hello, world", path="greeting.txt")
Use Git Diff to Compare files
With subprocess
:
from unchanged import Verifier
from subprocess import Popen
verify = Verifier(show_diffs=lambda f1, f2: Popen(['git' ,'diff', '--no-index', f1, f2]))
verify("Hello, world", path='greeting.txt')
With the unchanged.Program
utility:
from unchanged import Verifier, Program
verify = Verifier(show_diffs=Program(['git' ,'diff', '--no-index']))
verity("Hello world")
Use NBDime to Compare Jupyter Notebooks
from unchanged import Verifier
from subprocess import Popen
notebooks_match = lambda f1, f2: Popen(['nbdime', 'diff', '--ignore-metadata', f1, f2]).stdout.read() == ''
show_notebook_diff = lambda f1, f2: Popen(['nbdime', 'diff-web'])
verify_notebook = Verifier(show_diffs=Program(['nbdime', 'diff-web']), files_match=notebooks_match)
Use BeyondCompare 3 to Display Diffs
from unchanged import Verifier
from subprocess import Popen
path_to_bc3 = "{ProgramFiles}/Beyond Compare 4/BCompare.exe"
show_diff_in_BC3 = lambda f1, f2: Popen([path_to_bc3])
verify = Verifier(show_diffs=show_diff_in_BC3)
Check Matplotlib Plots, Displaying Diffs in VSCode
from unchanged import Verifier
from subprocess import Popen
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unchanged-0.2.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file unchanged-0.2.tar.gz
.
File metadata
- Download URL: unchanged-0.2.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa9b83df15acbae8b08140d2ab732743ba5b234d28e6de48756eccc7098504a2 |
|
MD5 | ce32d3264eaf1e171a209904a218b2cf |
|
BLAKE2b-256 | a27844b32cf80025420b764667ae1fa3ef640b52f0bb6685f7bd99949405593b |
File details
Details for the file unchanged-0.2-py3-none-any.whl
.
File metadata
- Download URL: unchanged-0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c28053bb34c4501b2e828caefbfae6225051d3f8fa5e799e404e85bdd27ae821 |
|
MD5 | 3cdabff8f0b2286128c08a91f6967d38 |
|
BLAKE2b-256 | a65c8fddf416d60669cc739891995b63a2b74cbc42e5500b1a207034d7a8f78c |