Skip to content

Commit 1c6f55b

Browse files
committed
MNT: move helper function
1 parent 496888c commit 1c6f55b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/matplotlib/tests/test_sphinxext.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414
minversion=None if sys.version_info < (3, 10) else '4.1.3')
1515

1616

17+
def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
18+
# Build the pages with warnings turned into errors
19+
extra_args = [] if extra_args is None else extra_args
20+
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
21+
'-d', str(doctree_dir), str(source_dir), str(html_dir), *extra_args]
22+
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
23+
env={**os.environ, "MPLBACKEND": ""})
24+
out, err = proc.communicate()
25+
26+
assert proc.returncode == 0, \
27+
f"sphinx build failed with stdout:\n{out}\nstderr:\n{err}\n"
28+
if err:
29+
pytest.fail(f"sphinx build emitted the following warnings:\n{err}")
30+
31+
assert html_dir.is_dir()
32+
33+
1734
def test_tinypages(tmp_path):
1835
shutil.copytree(Path(__file__).parent / 'tinypages', tmp_path,
1936
dirs_exist_ok=True)
@@ -159,20 +176,3 @@ def test_show_source_link_false(tmp_path, plot_html_show_source_link):
159176
build_sphinx_html(tmp_path, doctree_dir, html_dir, extra_args=[
160177
'-D', f'plot_html_show_source_link={plot_html_show_source_link}'])
161178
assert len(list(html_dir.glob("**/index-1.py"))) == 0
162-
163-
164-
def build_sphinx_html(tmp_path, doctree_dir, html_dir, extra_args=None):
165-
# Build the pages with warnings turned into errors
166-
extra_args = [] if extra_args is None else extra_args
167-
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
168-
'-d', str(doctree_dir), str(tmp_path), str(html_dir), *extra_args]
169-
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
170-
env={**os.environ, "MPLBACKEND": ""})
171-
out, err = proc.communicate()
172-
173-
assert proc.returncode == 0, \
174-
f"sphinx build failed with stdout:\n{out}\nstderr:\n{err}\n"
175-
if err:
176-
pytest.fail(f"sphinx build emitted the following warnings:\n{err}")
177-
178-
assert html_dir.is_dir()

0 commit comments

Comments
 (0)