I have just released a small plugin for py.test that wraps the image
comparison functionality in matplotlib.testing, for use in other
packages that use py.test as the testing framework instead of nose:
The idea is to make it easy to write a test such as:
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
which can then be run in three ways:
- Running py.test as usual will simply check the tests run but won't
check whether the figure is correct.
- Running py.test with the --mpl option will make sure that the figure
produced by the test is the same as a reference image
- Running py.test with the --mpl-generate-path option will generate the
reference images from the tests themselves.
There are a number of other options, including ways to pass arguments to
savefig, customizing the image names, or setting the tolerance for the
comparison. All the documentation is contained in the README.md file:
You can install this plugin with:
pip install pytest-mpl
I would welcome any feedback and/or contributions!