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 in your pytest framework. Golden testing is a methodology that compares the output of your code with a pre-recorded output, allowing you to simplify your tests by reducing explicit assertions. 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: .. code-block:: bash

$ 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.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-goldie-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 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.1.tar.gz
Algorithm Hash digest
SHA256 1481fe68805f664476449e6bb4a8d1cc5d1d7d22fb14a046d51208874ed1f3e2
MD5 5ac0d77b8c8174e357fb88c61632c362
BLAKE2b-256 7e24d08fbfdafca0db4042dc652ed8f938d4e00b65f665559a3e3a3c044cd349

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_goldie-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for pytest_goldie-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36c8c8af8f5597f2d37ce17aba1df05a00e29c4c4b51becf1e3a46204dc8e732
MD5 1329fb65477100e368f8ccde4ab551db
BLAKE2b-256 1b8a3fdc629d66cc7a529d917313760b87d0ba8b3674fe159d1029a898232b38

See more details on using hashes here.

Supported by

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