Skip to content

Commit aeb3cfc

Browse files
committed
Simplify some Sphinx tests
- `test_tinypages` unnecessarily calls `sphinx-build` twice. - `test_srcset_versions` doesn't need an extra copy of the source files, as it doesn't modify anything.
1 parent 903d537 commit aeb3cfc

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

lib/matplotlib/tests/test_sphinxext.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
2121
extra_args = [] if extra_args is None else extra_args
2222
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
2323
'-d', str(doctree_dir), str(source_dir), str(html_dir), *extra_args]
24+
# On CI, gcov emits warnings (due to agg headers being included with the
25+
# same name in multiple extension modules -- but we don't care about their
26+
# coverage anyways); hide them using GCOV_ERROR_FILE.
2427
proc = subprocess_run_for_testing(
2528
cmd, capture_output=True, text=True,
26-
env={**os.environ, "MPLBACKEND": ""})
29+
env={**os.environ, "MPLBACKEND": "", "GCOV_ERROR_FILE": os.devnull}
30+
)
2731
out = proc.stdout
2832
err = proc.stderr
2933

@@ -40,18 +44,6 @@ def test_tinypages(tmp_path):
4044
html_dir = tmp_path / '_build' / 'html'
4145
img_dir = html_dir / '_images'
4246
doctree_dir = tmp_path / 'doctrees'
43-
# Build the pages with warnings turned into errors
44-
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
45-
'-d', str(doctree_dir), str(tinypages), str(html_dir)]
46-
# On CI, gcov emits warnings (due to agg headers being included with the
47-
# same name in multiple extension modules -- but we don't care about their
48-
# coverage anyways); hide them using GCOV_ERROR_FILE.
49-
proc = subprocess_run_for_testing(
50-
cmd, capture_output=True, text=True,
51-
env={**os.environ, "MPLBACKEND": "", "GCOV_ERROR_FILE": os.devnull}
52-
)
53-
out = proc.stdout
54-
err = proc.stderr
5547

5648
# Build the pages with warnings turned into errors
5749
build_sphinx_html(tmp_path, doctree_dir, html_dir)
@@ -185,13 +177,12 @@ def test_show_source_link_false(tmp_path, plot_html_show_source_link):
185177

186178

187179
def test_srcset_version(tmp_path):
188-
shutil.copytree(tinypages, tmp_path, dirs_exist_ok=True)
189180
html_dir = tmp_path / '_build' / 'html'
190181
img_dir = html_dir / '_images'
191182
doctree_dir = tmp_path / 'doctrees'
192183

193-
build_sphinx_html(tmp_path, doctree_dir, html_dir, extra_args=[
194-
'-D', 'plot_srcset=2x'])
184+
build_sphinx_html(tinypages, doctree_dir, html_dir,
185+
extra_args=['-D', 'plot_srcset=2x'])
195186

196187
def plot_file(num, suff=''):
197188
return img_dir / f'some_plots-{num}{suff}.png'

0 commit comments

Comments
 (0)