110110 from matplotlib.testing.decorators import image_comparison
111111 import matplotlib.pyplot as plt
112112
113- @image_comparison(baseline_images=['spines_axes_positions'])
113+ @image_comparison(baseline_images=['spines_axes_positions'],
114+ extensions=['png'])
114115 def test_spines_axes_positions():
115116 # SF bug 2852168
116117 fig = plt.figure()
@@ -128,23 +129,28 @@ it::
128129
129130The first time this test is run, there will be no baseline image to
130131compare against, so the test will fail. Copy the output images (in
131- this case `result_images/test_category/spines_axes_positions.* `) to
132+ this case `result_images/test_category/spines_axes_positions.png `) to
132133the correct subdirectory of `baseline_images ` tree in the source
133134directory (in this case
134- `lib/matplotlib/tests/baseline_images/test_category `). Note carefully
135- the `.* ` at the end: this will copy only the images we need to include
136- in the `git ` repository. The files ending in `_pdf.png ` and
137- `_svg.png ` are converted from the `pdf ` and `svg ` originals on the fly
138- and do not need to be in the respository. Put these new files under
139- source code revision control (with `git add `). When rerunning the
140- tests, they should now pass.
135+ `lib/matplotlib/tests/baseline_images/test_category `). Put this new
136+ file under source code revision control (with `git add `). When
137+ rerunning the tests, they should now pass.
138+
139+ The :func: `~matplotlib.testing.decorators.image_comparison ` decorator
140+ defaults to generating ``png ``, ``pdf `` and ``svg `` output, but in
141+ interest of keeping the size of the library from ballooning we should only
142+ include the ``svg `` or ``pdf `` outputs if the test is explicitly exercising
143+ a feature dependent on that backend.
141144
142145There are two optional keyword arguments to the `image_comparison `
143146decorator:
144147
145- - `extensions `: If you only wish to test some of the image formats
146- (rather than the default `png `, `svg ` and `pdf ` formats), pass a
147- list of the extensions to test.
148+ - `extensions `: If you only wish to test additional image formats
149+ (rather than just `png `), pass any additional file types in the
150+ list of the extensions to test. When copying the new
151+ baseline files be sure to only copy the output files, not their
152+ conversions to ``png ``. For example only copy the files
153+ ending in ``pdf ``, not in ``_pdf.png ``.
148154
149155 - `tol `: This is the image matching tolerance, the default `1e-3 `.
150156 If some variation is expected in the image between runs, this
0 commit comments