Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for setting a non-agg Matplotlib backend #1104

Merged
merged 2 commits into from Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx_gallery/tests/test_full.py
Expand Up @@ -30,7 +30,7 @@

# total number of plot_*.py files in tinybuild/examples + examples_rst_index
# + examples_with_rst
N_EXAMPLES = 13 + 3 + 2
N_EXAMPLES = 14 + 3 + 2
N_FAILING = 2
N_GOOD = N_EXAMPLES - N_FAILING # galleries that run w/o error
# passthroughs examples_rst_index, examples_with_rst
Expand Down
24 changes: 24 additions & 0 deletions sphinx_gallery/tests/tinybuild/examples/plot_matplotlib_backend.py
@@ -0,0 +1,24 @@
"""
Setting the Matplotlib backend
==============================
"""

# %%
# The Matplotlib backend should start as `agg`

import matplotlib
print(f"Matplotlib backend is {matplotlib.get_backend()}")
assert matplotlib.get_backend() == "agg"

# %%
# Changing the Matplotlib backend to `svg` should be possible

matplotlib.use("svg")
print(f"Matplotlib backend is {matplotlib.get_backend()}")
assert matplotlib.get_backend() == "svg"

# %%
# In a new code block, the Matplotlib backend should continue to be `svg`

print(f"Matplotlib backend is {matplotlib.get_backend()}")
assert matplotlib.get_backend() == "svg"