Pytest-plt 1.0.1 released

The Nengo team at ABR is excited to announce the first release of pytest-plt 1.0.1.

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 plt fixture.

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()

test_rectification.png

To generate the plot, pass --plots to pytest.

pytest --plots

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.

What’s new?

Pytest-plt 1.0.1 is a bugfix release that makes pytest-plt compatible with Windows. The plot filenames that we used in 1.0.0 contained colons, which are not valid on Windows. Version 1.0.1 replaces those colons with hyphens that work on Windows and are still human-readable.

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.