Open
Description
There's lots of tests in tests/test_pytest_mpl.py
which write test code to a temp file, run it, and check the result. Pytest's builtin pytester plugin is designed for doing this and has lots of nice features for checking the outcome.
https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#testing-plugins