Skip to main content

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()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goldie-0.1.9.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goldie-0.1.9-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file goldie-0.1.9.tar.gz.

File metadata

  • Download URL: goldie-0.1.9.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for goldie-0.1.9.tar.gz
Algorithm Hash digest
SHA256 146332b9e133ebeea8e96508a9995e1201d834212d25d0158141c03929d663c3
MD5 425a564ff7cbd4a9b647b1ffbbe2b773
BLAKE2b-256 92c1212c30aa6313a77fbf1b46b148ff2a83ab140be92418cc3e31b18200de58

See more details on using hashes here.

Provenance

The following attestation bundles were made for goldie-0.1.9.tar.gz:

Publisher: release.yml on merschformann/goldie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goldie-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: goldie-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for goldie-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e1cc6167f135f8e0e3320b1eb7f7b7f267de1cf97377d6a43bec9ee8a29f78b4
MD5 4e26cb623f7239b7bc40e3af096df13e
BLAKE2b-256 eb185d64a3722761febbf947f4324d7a87fe5a4b32dbcf84319d26bcb31b5d48

See more details on using hashes here.

Provenance

The following attestation bundles were made for goldie-0.1.9-py3-none-any.whl:

Publisher: release.yml on merschformann/goldie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page