A humble library greasing the gears of golden file tests
Project description
goldie
A humble library greasing the gears of golden file tests.
Installation
pip install goldie
Example
This is an example of how to use goldie to test a script across multiple JSON files. The golden files will be used as a reference to compare the output of the script. Adding GOLDIE_UPDATE=1 to the environment variables will update the golden files with the output of the script. Find the full example in the example directory.
import unittest
import goldie
class TestExample(unittest.TestCase):
def test_script(self):
config = goldie.ConfigDirectoryTest(
# We want to test all JSON files in the data directory.
file_filter="data/*.json",
config_file_test=goldie.ConfigFileTest(
run_configuration=goldie.ConfigRun(
# We simply run the script in this directory.
cmd="python",
args=["script.py"],
# The script reads from stdin and writes to stdout.
input_mode=goldie.InputMode.STDIN,
output_mode=goldie.OutputMode.STDOUT,
),
comparison_configuration=goldie.ConfigComparison(
# We want to leverage the JSON structure instead of comparing raw strings.
comparison_type=goldie.ComparisonType.JSON,
json_processing_config=goldie.ConfigProcessJson(
replacements=[
# We want to replace an unstable value with a stable one.
goldie.JsonReplacement(path="data.random", value=3),
],
),
),
),
)
goldie.testing.run_directory_unittest(self, config)
if __name__ == "__main__":
unittest.main()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file goldie-0.1.8.tar.gz.
File metadata
- Download URL: goldie-0.1.8.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3660c89f92d1ad9ab5d4f55c75a59d442ebf7432e517fd4df6ad95c5d32a616b
|
|
| MD5 |
c6a20d55b555ab77a1e83a0ad2f7acf6
|
|
| BLAKE2b-256 |
1685bcb7cdb2f685eb9d09f60cb6eb3599bbeede9d33c06b9b72f3a0916c9d98
|
Provenance
The following attestation bundles were made for goldie-0.1.8.tar.gz:
Publisher:
release.yml on merschformann/goldie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
goldie-0.1.8.tar.gz -
Subject digest:
3660c89f92d1ad9ab5d4f55c75a59d442ebf7432e517fd4df6ad95c5d32a616b - Sigstore transparency entry: 633755272
- Sigstore integration time:
-
Permalink:
merschformann/goldie@6838c60c5f53b081cbdd36128a95791d416b82c0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/merschformann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6838c60c5f53b081cbdd36128a95791d416b82c0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file goldie-0.1.8-py3-none-any.whl.
File metadata
- Download URL: goldie-0.1.8-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
893d63d6c55271e68a9d98730c9a590d0668f2e382cf439965529b707d21d1dc
|
|
| MD5 |
39f747e9f79baf07601e23516538cff6
|
|
| BLAKE2b-256 |
b8e04d6b1bc6cdeee5cf157e0a4b6c4287c4ed3aa3df04bee2af4ba58f525706
|
Provenance
The following attestation bundles were made for goldie-0.1.8-py3-none-any.whl:
Publisher:
release.yml on merschformann/goldie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
goldie-0.1.8-py3-none-any.whl -
Subject digest:
893d63d6c55271e68a9d98730c9a590d0668f2e382cf439965529b707d21d1dc - Sigstore transparency entry: 633755308
- Sigstore integration time:
-
Permalink:
merschformann/goldie@6838c60c5f53b081cbdd36128a95791d416b82c0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/merschformann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6838c60c5f53b081cbdd36128a95791d416b82c0 -
Trigger Event:
workflow_dispatch
-
Statement type: