Skip to main content
PyPI version Python versions See Build Status on GitHub Actions

A plugin to use approvaltests with pytest

Features

  • command line options to choose which reporter to use on approval test failure

  • define your own diff reporter to use on approval test failure

Requirements

approvaltests

Installation

You can install “pytest-approvaltests” via pip from PyPI:

$ pip install pytest-approvaltests

Usage

See also the documentation for approval tests

When your approval tests fail and you are working interactively, you might like it to open another diff tool than when you are on a CI server for example.

This plugin allows you to configure pytest with which diff tool to use when tests fail.

To set the default reporter to ‘PythonNativeReporter’, suitable for use on the command line:

pytest –approvaltests-use-reporter=’PythonNativeReporter’

To define your own diff reporter, perhaps a program with a rich GUI installed only on your developer workstation:

pytest –approvaltests-add-reporter=”diff_program”

The value for ‘approvaltests-add-reporter’ should be an executable program that can diff two files received as arguments on the command line like this:

diff_program filepath1 filepath2

if it takes additional arguments, add them with ‘approvaltests-add-reporter-args’:

pytest –approvaltests-add-reporter=”diff_program” –approvaltests-add-reporter-args=”arg1,arg2”

They will be inserted like this:

diff_program arg1 arg2 filepath1 filepath2

Tip for Jetbrains toolbox and PyCharm users

You can use PyCharm as a diff tool, which is convenient if you are also using it as an IDE. Especially if you’re using Toolbox, it can be difficult to find the actual executable to pass to pytest. You could try this while PyCharm is running:

ps -ef | grep PyCharm

If you’re lucky it will show the full path to the PyCharm that is executing. It may not be pretty. However, then you can configure pytest with arguments something like this:

–approvaltests-add-reporter-args=’diff’ –approvaltests-add-reporter=’/Users/emily/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/192.6262.63/PyCharm.app/Contents/MacOS/pycharm’

In PyCharm, you can create a new ‘run configuration’ (see the [documentation](https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html)). Add a configuration using the ‘+’ button, choose “python tests | pytest”. Add these arguments to set the reporter for pytest under ‘Additional Arguments’.

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-approvaltests” is free and open source software

Issues

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

Developer Notes

To release a new version on pypi:

python setup.py install

check it created an egg file under dist

python -m twine upload dist/pytest_approvaltests-<version>-py3.7.egg

You will need to enter a valid username and password for pypi

Release files for pytest-approvaltests 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-approvaltests 0.2.4
File Size Uploaded
pytest-approvaltests-0.2.4.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-approvaltests 0.2.4
File Interpreter ABI Platform
pytest_approvaltests-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / pytest-approvaltests-0.2.4.tar.gz

Download URL pytest-approvaltests-0.2.4.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
325fafdc1ed49d10f88f072c3305b3d35557cbc15748d835be3020db4092e9a6
BLAKE2b-256 checksum
How to use checksums
0cd6a47683426ac614b7588fcf0c802b119668c429b82175c2cbeb576d0ca99a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / pytest_approvaltests-0.2.4-py3-none-any.whl

Download URL pytest_approvaltests-0.2.4-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
199ad1cac8ebcbf681f4876d07bf3bbb8bdfa49396e16747027f6bac2fa0a075
BLAKE2b-256 checksum
How to use checksums
6af63b72ee9a7ddc48fd21295be19e449239afb1eb45dd6e0e1c6f74c535b3d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

1 release file

0.1.1

1 release file

0.1.0

3 release 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