Metadata-Version: 2.2
Name: pytest-matcher
Version: 1.3.3
Summary: Match test output against patterns stored in files
Home-page: http://zaufi.github.io/programming/2017/07/05/extend-pytest-with-fixtures
Download-URL: https://github.com/zaufi/pytest-matcher/archive/release/1.3.3.tar.gz
Author: Alex Turbov
Author-email: i.zaufi@gmail.com
License: GPLv3+
Project-URL: Source, https://github.com/zaufi/pytest-matcher,
Project-URL: Tracker, https://github.com/zaufi/pytest-matcher/issues
Keywords: pytest plugin
Platform: any
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 5 - Production/Stable
Classifier: Topic :: Software Development :: Testing
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Requires: p
Requires: y
Requires: t
Requires: e
Requires: s
Requires: t
Requires-Python: ~=3.4
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: pytest>=3.4
Requires-Dist: PyYAML>=3.12
Requires-Dist: setuptools>=39.2.0
Dynamic: download-url
Dynamic: requires
Dynamic: requires-dist

What is this
============

|Build Status| |nbsp| |Latest Release|

This is a pytest plugin which provides a couple of fixtures to match
test output against patterns stored in files.

The plugin extends pytest with the following CLI options:

- ``--pm-save-patterns`` -- to store the output to a pattern file (instead of checking);
- ``--pm-patterns-base-dir`` to specify a base directory, where to lookup pattern files.

Pattern files are stored in a base directory and additional paths based on test module
name, test class name and/or test function name as following:

::

    <base-dir>/<test-module-name>/[test-class-name/]<test-function-name>

Note, that for non-class test functions the *test-class-name* part is absent.


Quick Start
===========

The plugin provides ``expected_out`` and ``expected_err``
named fixture functions.


.. code-block:: python

    def test_foo(capfd, expected_out):
        print('foo')

        stdout, stderr = capfd.readouterr()

        assert stdout == expected_out

Add ``pm-patterns-base-dir`` option to ``pytest.ini`` file (and ``pytest`` section)
pointing for example to ``test/data/expected``. For the first ``pytest`` run it would
fail, cuz there is no expected pattern file present. To write it one can use
``pytest`` CLI:

::

    $ pytest --pm-save-patterns test/test_foo.py::test_foo

Review the stored pattern file and add to your VCS.


See Also
========

* `How it works <http://zaufi.github.io/programming/2017/07/05/extend-pytest-with-fixtures>`_

.. |Latest Release| image:: https://badge.fury.io/py/pytest-matcher.svg
    :target: https://pypi.org/project/pytest-matcher/#history
.. |Build Status| image:: https://travis-ci.org/zaufi/pytest-matcher.svg?branch=master
   :target: https://travis-ci.org/zaufi/pytest-matcher
.. |nbsp| unicode:: 0xA0
   :trim:
