Skip to content

A plugin for pytest which allows to compare results with canonical results, based on previous runs

License

Notifications You must be signed in to change notification settings

shuternay/pytest-canonical-data

Repository files navigation

pytest-canonical-data

PyPI version Python versions See Build Status on Travis CI See Build Status on AppVeyor

A plugin which allows to compare results with canonical results, based on previous runs.


Inspired by Yandex's canondata plugin, pytest-needle and pytest-regtest.

This pytest plugin was generated with Cookiecutter along with @hackebrot's cookiecutter-pytest-plugin template.

Installation

You can install "pytest-canonical-data" via pip from PyPI:

$ pip install pytest-canonical-data

Usage

Plugin provides canonical_data fixture, which allows to create canonical results:

def test_sth(canonical_data):
    # In the default mode will compare the `result.txt` canonical result with `123` string using `str` driver
    # In the canonize mode will save `123` as the `result.txt` canonical result
    assert canonical_data('result.txt', 'text') == '123'

To run in canonize mode execute:

pytest --canonize

It will create files with canonical results (if don't exist) and save actual results.

The plugin saves canonical results in canonical_data directory next to the test file. It also saves actual results values in _output_data directory (for debug purposes).

Drivers

You need to use appropriate driver for each data type. Currently, there are the following drivers:

  • bytes: for comparing bytes sequences.
  • str: for comparing python strings.
  • json: for comparing objects which can be loaded from and dumped to json.

TODO

  • Driver for images
  • Driver for json
  • HTML reports for images

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, "pytest-canonical-data" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

About

A plugin for pytest which allows to compare results with canonical results, based on previous runs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages