Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e61c62d

Browse filesBrowse files
authored
Merge pull request #11934 from anntzer/plotdirective-patchshow
DOC: Suppress the "non-GUI backend" warning from the .. plot:: directive...
2 parents 98a0821 + 13239b5 commit e61c62d
Copy full SHA for e61c62d

File tree

Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed

‎lib/matplotlib/sphinxext/plot_directive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
import jinja2 # Sphinx dependency.
157157

158158
import matplotlib
159+
from matplotlib.backend_bases import FigureManagerBase
159160
try:
160161
with warnings.catch_warnings(record=True):
161162
warnings.simplefilter("error", UserWarning)
@@ -491,9 +492,13 @@ def run_code(code, code_path, ns=None, function_name=None):
491492
exec(str(setup.config.plot_pre_code), ns)
492493
if "__main__" in code:
493494
ns['__name__'] = '__main__'
494-
exec(code, ns)
495-
if function_name is not None:
496-
exec(function_name + "()", ns)
495+
496+
# Patch out non-interactive show() to avoid triggering a warning.
497+
with cbook._setattr_cm(FigureManagerBase, show=lambda self: None):
498+
exec(code, ns)
499+
if function_name is not None:
500+
exec(function_name + "()", ns)
501+
497502
except (Exception, SystemExit) as err:
498503
raise PlotError(traceback.format_exc())
499504
finally:

‎lib/matplotlib/sphinxext/tests/test_tinypages.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/tests/test_tinypages.py
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ def test_tinypages(tmpdir):
1919
# Build the pages with warnings turned into errors
2020
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html', '-d', doctree_dir,
2121
pjoin(dirname(__file__), 'tinypages'), html_dir]
22-
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
22+
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
2323
out, err = proc.communicate()
2424
assert proc.returncode == 0, \
25-
"'{} -msphinx' failed with stdout:\n{}\nstderr:\n{}\n".format(
26-
sys.executable, out, err)
25+
"sphinx build failed with stdout:\n{}\nstderr:\n{}\n".format(out, err)
26+
if err:
27+
pytest.fail("sphinx build emitted the following warnings:\n{}"
28+
.format(err))
2729

2830
assert isdir(html_dir)
2931

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.