Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
pytest-mpl
pytest-mpl
is a pytest <https://docs.pytest.org>
__ plugin to facilitate image comparison for Matplotlib <http://www.matplotlib.org>
__ figures.
For each figure to test, an image is generated and then subtracted from an existing reference image. If the RMS of the residual is larger than a user-specified tolerance, the test will fail. Alternatively, the generated image can be hashed and compared to an expected value.
For more information, see the pytest-mpl documentation <https://pytest-mpl.readthedocs.io>
__.
.. code-block:: bash
pip install pytest-mpl
For detailed instructions, see the installation guide <https://pytest-mpl.readthedocs.io/en/latest/installing.html>
__ in the pytest-mpl
docs.
First, write test functions that create a figure.
These image comparison tests are decorated with @pytest.mark.mpl_image_compare
and return the figure for testing:
.. code-block:: python
import matplotlib.pyplot as plt import pytest
@pytest.mark.mpl_image_compare def test_plot(): fig, ax = plt.subplots() ax.plot([1, 2]) return fig
Then, generate reference images by running the test suite with the --mpl-generate-path
option:
.. code-block:: bash
pytest --mpl-generate-path=baseline
Then, run the test suite as usual, but pass --mpl
to compare the returned figures to the reference images:
.. code-block:: bash
pytest --mpl
By also passing --mpl-generate-summary=html
, a summary of the image comparison results will be generated in HTML format:
+---------------+---------------+---------------+ | |html all| | |html filter| | |html result| | +---------------+---------------+---------------+
For more information on how to configure and use pytest-mpl
, see the pytest-mpl documentation <https://pytest-mpl.readthedocs.io>
__.
pytest-mpl
is a community project maintained for and by its users.
There are many ways you can help!
on GitHub <https://github.com/matplotlib/pytest-mpl/issues>
__.. |html all| image:: docs/images/html_all.png .. |html filter| image:: docs/images/html_filter.png .. |html result| image:: docs/images/html_result.png
FAQs
pytest plugin to help with testing figures output from Matplotlib
We found that pytest-mpl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.