The Nengo team at ABR is excited to announce the first release of
What is pytest-plt?
pytest-plt makes plotting in your tests easy by providing a
plt fixture for pytest.
Create PDF plots in one line with the
import numpy as np def test_rectification(plt): values = list(range(-10, 11)) rectified = [v if v > 0 else 0 for v in values] assert all(v >= 0 for v in rectified) plt.plot(values, label="Original") plt.plot(rectified, label="Rectified") plt.legend()
To generate the plot, pass
If you don’t pass
--plots, calls to
plt function will be ignored, meaning that your tests won’t spend time making plots that won’t get saved.
Pytest-plt 1.1.0 allows plots to be saved in
pickle format (simply by adding the
*.pkl extension). This means that you can re-open the plots in matplotlib and inspect them using any of the tools available there. Thanks to @joniemi for the new feature!
Where can I learn more?
pytest-plt gives you several ways to customize the directory that your plots end up in, and the filenames of all the plots in that directory. For the full details, see the documentation.
Where can I get help?
If you have any questions, run into any bugs, or have suggestions for new features, please file an issue on Github.