1- |Travis Build Status | |AppVeyor Build status | | Coveralls coverage |
1+ |Travis Build Status | |Coveralls coverage |
22
33About
44-----
55
66This is a plugin to facilitate image comparison for
77`Matplotlib <http://www.matplotlib.org >`__ figures in pytest.
88
9- Matplotlib includes a number of test utilities and decorators, but these
10- are geared towards the `nose <http://nose.readthedocs.org/ >`__ testing
11- framework. Pytest-mpl makes it easy to compare figures produced by tests
12- to reference images when using `pytest <http://pytest.org >`__.
13-
149For each figure to test, the reference image is subtracted from the
1510generated image, and the RMS of the residual is compared to a
1611user-specified tolerance. If the residual is too large, the test will
@@ -23,23 +18,17 @@ section below.
2318Installing
2419----------
2520
26- This plugin is compatible with Python 2.6, 2.7, and 3.3 and later, and
27- requires `pytest <http://pytest.org >`__,
28- `matplotlib <http://www.matplotlib.org >`__ and
29- `nose <http://nose.readthedocs.org/ >`__ to be installed (nose is
30- required by Matplotlib).
31-
32- To install, you can do:
21+ This plugin is compatible with Python 2.7, and 3.5 and later, and
22+ requires `pytest <http://pytest.org >`__ and
23+ `matplotlib <http://www.matplotlib.org> ` to be installed.
3324
34- ::
25+ To install, you can do ::
3526
3627 pip install pytest-mpl
3728
38- You can check that the plugin is registered with pytest by doing:
39-
40- ::
29+ You can check that the plugin is registered with pytest by doing::
4130
42- py.test --version
31+ pytest --version
4332
4433which will show a list of plugins:
4534
@@ -71,24 +60,20 @@ function returns a Matplotlib figure (or any figure object that has a
7160
7261 To generate the baseline images, run the tests with the
7362``--mpl-generate-path `` option with the name of the directory where the
74- generated images should be placed:
75-
76- ::
63+ generated images should be placed::
7764
78- py.test --mpl-generate-path=baseline
65+ pytest --mpl-generate-path=baseline
7966
8067If the directory does not exist, it will be created. The directory will
81- be interpreted as being relative to where you are running ``py.test ``.
68+ be interpreted as being relative to where you are running ``pytest ``.
8269Once you are happy with the generated images, you should move them to a
8370sub-directory called ``baseline `` relative to the test files (this name
8471is configurable, see below). You can also generate the baseline images
8572directly in the right directory.
8673
87- You can then run the tests simply with:
74+ You can then run the tests simply with::
8875
89- ::
90-
91- py.test --mpl
76+ pytest --mpl
9277
9378and the tests will pass if the images are the same. If you omit the
9479``--mpl `` option, the tests will run but will only check that the code
@@ -145,11 +130,9 @@ a comma-separated list of URLs (real commas in the URL should be encoded
145130as ``%2C ``).
146131
147132Finally, you can also set a custom baseline directory globally when
148- running tests by running ``py.test `` with:
149-
150- ::
133+ running tests by running ``pytest `` with::
151134
152- py.test --mpl --mpl-baseline-path=baseline_images
135+ pytest --mpl --mpl-baseline-path=baseline_images
153136
154137This directory will be interpreted as being relative to where the tests
155138are run. In addition, if both this option and the ``baseline_dir ``
@@ -190,9 +173,7 @@ Test failure example
190173
191174If the images produced by the tests are correct, then the test will
192175pass, but if they are not, the test will fail with a message similar to
193- the following:
194-
195- ::
176+ the following::
196177
197178 E Exception: Error: Image files did not match.
198179 E RMS Value: 142.2287807767823
@@ -226,7 +207,7 @@ By default, the expected, actual and difference files are written to a
226207temporary directory with a non-deterministic path. If you want to instead
227208write them to a specific directory, you can use::
228209
229- py.test --mpl --mpl-results-path=results
210+ pytest --mpl --mpl-results-path=results
230211
231212The ``results `` directory will then contain one sub-directory per test, and each
232213sub-directory will contain the three files mentioned above. If you are using a
@@ -242,20 +223,16 @@ Running the tests for pytest-mpl
242223--------------------------------
243224
244225If you are contributing some changes and want to run the tests, first
245- install the latest version of the plugin then do:
246-
247- ::
226+ install the latest version of the plugin then do::
248227
249228 cd tests
250- py.test --mpl
229+ pytest --mpl
251230
252231The reason for having to install the plugin first is to ensure that the
253232plugin is correctly loaded as part of the test suite.
254233
255234.. |Travis Build Status | image :: https://travis-ci.org/matplotlib/pytest-mpl.svg?branch=master
256235 :target: https://travis-ci.org/matplotlib/pytest-mpl
257- .. |AppVeyor Build status | image :: https://ci.appveyor.com/api/projects/status/mf7hs44scg5mvcyo?svg=true
258- :target: https://ci.appveyor.com/project/astrofrog/pytest-mpl
259236.. |Coveralls coverage | image :: https://coveralls.io/repos/matplotlib/pytest-mpl/badge.svg
260237 :target: https://coveralls.io/r/matplotlib/pytest-mpl
261238.. |expected | image :: images/baseline-coords_overlay_auto_coord_meta.png
0 commit comments