/pytest-clarity

A plugin to improve the output of pytest with colourful unified diffs

Primary LanguagePythonMIT LicenseMIT

pytest-clarity

PyPI version conda-forge version Python versions See Build Status on Travis CI

A plugin to improve the readability of pytest output.

Features

  • Enables an easier to parse and more understandable diff for your failing tests.
  • Can display unified diffs or split diffs, and chooses them depending on the context.
  • Adds helpful hints to the output for failing tests to help you track down common issues.

With pytest-clarity:

Example output with clarity

The same test, without pytest-clarity:

Example output without clarity

Requirements

Supports Python 2.7 and 3.4+

Installation

You can install "pytest-clarity" via pip from PyPI:

$ pip install pytest-clarity

Usage

Install the plugin as described above.

** The plugin will only be activated when the -vv option is supplied to pytest.**

You can choose which type of diff you want with --diff-type (auto (default), split or unified):

pytest -vv --diff-type=split

You can disable hints using the --no-hints flag:

pytest -vv --no-hints

You can configure the width of the output with the --diff-width option:

pytest -vv --diff-width=60

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-clarity" is free and open source software.

Issues

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

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