Use a non-interactive matplotlib backend for the test suite
#656
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried running the
autotest\plot_tests.py::pst_plot_testtest locally, but I got Tkinter errors.Details
In my experience, this is quite common under pytest.The details are a bit murky to me, but my understanding is that Tkinter is a Python wrapper around Tcl/Tk, which consists of the C libraries and a set of Tcl scripts. Internally, Python uses environment variables like TCL_LIBRARY and TK_LIBRARY to find these scripts, but it can be a fragile affair when there are virtual environments involved, pytest etc.
The default GitHub Windows runners use Python builds which tend to have this issue.
https://github.com/orgs/community/discussions/26434
By default,
matplotlibuses Tkinter as an interactive backend, but you can set it to use Agg instead, which is non-interactive (and faster). Interactivity (e.g. the ability to zoom in etc.) isn't really necessary in a test environment, since usually you usually don't even look at the plots anyway.The CI config already uses it:
pyemu/.github/workflows/ci.yml
Line 135 in 5dd3c78
So this change just brings uniformity for local tests too.