Skip to content

Commit b2ff453

Browse files
committed
Add tests
1 parent 780ea18 commit b2ff453

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/matplotlib/tests/test_sphinxext.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,23 @@ def plot_directive_file(num):
9595
# contents are the same)
9696
assert plot_directive_file(5).stat().st_mtime > modification_times[3]
9797
assert filecmp.cmp(range_6, plot_file(5))
98-
99-
100-
def build_sphinx_html(source_dir, doctree_dir, html_dir):
98+
# Make sure that source scripts are generated by default
99+
assert "some_plots-1.py" in [p.name for p in html_dir.iterdir()]
100+
# Make sure that source scripts are NOT generated when
101+
# `plot_html_show_source_link` is set to False
102+
html_dir = source_dir / '_build' / 'html_no_source'
103+
# `plot_html_show_source_link=0` is equivalent to
104+
# `plot_html_show_source_link=False`
105+
build_sphinx_html(source_dir, doctree_dir, html_dir,
106+
extra_args=["-D", "plot_html_show_source_link=0"])
107+
assert "some_plots-1.py" not in [p.name for p in html_dir.iterdir()]
108+
109+
110+
def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
101111
# Build the pages with warnings turned into errors
112+
extra_args = [] if extra_args is None else extra_args
102113
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
103-
'-d', str(doctree_dir), str(source_dir), str(html_dir)]
114+
'-d', str(doctree_dir), str(source_dir), str(html_dir)] + extra_args
104115
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
105116
env={**os.environ, "MPLBACKEND": ""})
106117
out, err = proc.communicate()

0 commit comments

Comments
 (0)