Skip to main content

A plugin to support golden tests with pytest.

Project description

PyPI version https://img.shields.io/pypi/l/pytest-goldie.svg

pytest-goldie is a pytest plugin that enables golden testing using pytest framework. Golden testing is a methodology that compares the output of your code with a pre-recorded output. This package provides a fixture called golden that can be used to update test results and make test comparisons.

Example

First, install the plugin:

$ pip install pytest-goldie

Then, in your test file, use the golden fixture:

def my_function():
    return "Hello, world!"

def test_my_function(golden):
    output = my_function()
    golden.test(output)

The golden.test method takes the output of your function and compares it to the saved output of a previous run. If the update_goldens flag is set, pytest-goldie will update the saved output with the new output.

To run the tests and update goldens, use the following command:

$ pytest --update_goldens

By default, the golden files are stored in a folder named ‘goldens’. You can change the folder name with –goldens_folder flag:

$ pytest --goldens_folder my_goldens

This will set the goldens folder to “my_goldens” instead of the default “goldens”.

License

This software is licensed under the MIT License.

Created by Nick Kartashov and contributors.

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

pytest-goldie-0.1.5.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

pytest_goldie-0.1.5-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest-goldie-0.1.5.tar.gz.

File metadata

  • Download URL: pytest-goldie-0.1.5.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for pytest-goldie-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8aa3dc1dc282d66b5f4a09fd04ad0227e8b292f73585cc8393a58c9e8b602dc3
MD5 5d577e0a07afbe5a2ae715624e2b45d4
BLAKE2b-256 5c959ca5ddc92cf71c18a6e05fc877f67ec79bc8461f13b2dfaab44a37985dca

See more details on using hashes here.

File details

Details for the file pytest_goldie-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_goldie-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a7fc8c202733f2d0df1efbc6a7e7fc02645b009cd8354cbe4d97e3f8f7bb82b3
MD5 c99ae667b4e89d255f314ce1996c1586
BLAKE2b-256 0f5dab49825a8dcca065edcc04e078a6caf6786a5b6fd4126023c37d4f836c9e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page