A simple plugin to use with pytest
Project description
===========
pytest-diff
===========
.. image:: https://img.shields.io/pypi/v/pytest-diff.svg
:target: https://pypi.org/project/pytest-diff
:alt: PyPI version
.. image:: https://img.shields.io/pypi/pyversions/pytest-diff.svg
:target: https://pypi.org/project/pytest-diff
:alt: Python versions
.. image:: https://travis-ci.org/username/pytest-diff.svg?branch=master
:target: https://travis-ci.org/username/pytest-diff
:alt: See Build Status on Travis CI
.. image:: https://ci.appveyor.com/api/projects/status/github/username/pytest-diff?branch=master
:target: https://ci.appveyor.com/project/username/pytest-diff/branch/master
:alt: See Build Status on AppVeyor
A simple plugin to use with pytest
----
This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template.
Features
--------
* Readable diffs for failed tests
* Customizable diffs for your classes
Requirements
------------
* `pytest`
* `deepdiff`
* `pprintpp`
Installation
------------
You can install "pytest-diff" via `pip`_ from `PyPI`_::
$ pip install pytest-diff
Usage
-----
.. code-block:: python
class Person:
def __init__(self, name, age, favorites):
self.name = name
self.age = age
self.favorites = favorites
def test_person():
a = Person("Alice", age=21, favorites={"food": "spam", "movie": "Life of Brian"})
b = Person("Alice", age=21, favorites={"food": "eggs", "movie": "Life of Brian"})
assert a == b
Running `pytest` gives:
.. code-block:: python
______________________________ test_person ______________________________
def test_person():
a = Person("Alice", age=21, favorites={'food': 'spam', 'movie': 'Life of Brian'})
b = Person("Alice", age=21, favorites={'food': 'eggs', 'movie': 'Life of Brian'})
> assert a == b
E assert
E <test_person.Person object at 0x7fa326d769e8>
E ==
E <test_person.Person object at 0x7fa326d76be0>
E {'values_changed': {"root.favorites['food']": {'new_value': 'spam', 'old_value': 'eggs'}}}
examples/test_person.py:11: AssertionError
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-diff" is free and open source software
Issues
------
If you encounter any problems, please `file an issue`_ along with a detailed description.
.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
.. _`@hackebrot`: https://github.com/hackebrot
.. _`MIT`: http://opensource.org/licenses/MIT
.. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause
.. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt
.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0
.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin
.. _`file an issue`: https://github.com/username/pytest-diff/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`tox`: https://tox.readthedocs.io/en/latest/
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
pytest-diff
===========
.. image:: https://img.shields.io/pypi/v/pytest-diff.svg
:target: https://pypi.org/project/pytest-diff
:alt: PyPI version
.. image:: https://img.shields.io/pypi/pyversions/pytest-diff.svg
:target: https://pypi.org/project/pytest-diff
:alt: Python versions
.. image:: https://travis-ci.org/username/pytest-diff.svg?branch=master
:target: https://travis-ci.org/username/pytest-diff
:alt: See Build Status on Travis CI
.. image:: https://ci.appveyor.com/api/projects/status/github/username/pytest-diff?branch=master
:target: https://ci.appveyor.com/project/username/pytest-diff/branch/master
:alt: See Build Status on AppVeyor
A simple plugin to use with pytest
----
This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template.
Features
--------
* Readable diffs for failed tests
* Customizable diffs for your classes
Requirements
------------
* `pytest`
* `deepdiff`
* `pprintpp`
Installation
------------
You can install "pytest-diff" via `pip`_ from `PyPI`_::
$ pip install pytest-diff
Usage
-----
.. code-block:: python
class Person:
def __init__(self, name, age, favorites):
self.name = name
self.age = age
self.favorites = favorites
def test_person():
a = Person("Alice", age=21, favorites={"food": "spam", "movie": "Life of Brian"})
b = Person("Alice", age=21, favorites={"food": "eggs", "movie": "Life of Brian"})
assert a == b
Running `pytest` gives:
.. code-block:: python
______________________________ test_person ______________________________
def test_person():
a = Person("Alice", age=21, favorites={'food': 'spam', 'movie': 'Life of Brian'})
b = Person("Alice", age=21, favorites={'food': 'eggs', 'movie': 'Life of Brian'})
> assert a == b
E assert
E <test_person.Person object at 0x7fa326d769e8>
E ==
E <test_person.Person object at 0x7fa326d76be0>
E {'values_changed': {"root.favorites['food']": {'new_value': 'spam', 'old_value': 'eggs'}}}
examples/test_person.py:11: AssertionError
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-diff" is free and open source software
Issues
------
If you encounter any problems, please `file an issue`_ along with a detailed description.
.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
.. _`@hackebrot`: https://github.com/hackebrot
.. _`MIT`: http://opensource.org/licenses/MIT
.. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause
.. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt
.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0
.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin
.. _`file an issue`: https://github.com/username/pytest-diff/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`tox`: https://tox.readthedocs.io/en/latest/
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytest-diff-0.1.4.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for pytest_diff-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ea4532a93f9f04e9f0bce0e33051f4e2d12f104290ce34fa8f58f3b54ff63ec |
|
MD5 | de76089812db4c644a3be90d4b5cb4bb |
|
BLAKE2b-256 | b571dc0ad72ef5d081de3f937bae3c50ecf98b7424fcd09ebcd1040ae4052c4d |