|
14 | 14 | minversion=None if sys.version_info < (3, 10) else '4.1.3') |
15 | 15 |
|
16 | 16 |
|
| 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 | + |
17 | 34 | def test_tinypages(tmp_path): |
18 | 35 | shutil.copytree(Path(__file__).parent / 'tinypages', tmp_path, |
19 | 36 | dirs_exist_ok=True) |
@@ -159,20 +176,3 @@ def test_show_source_link_false(tmp_path, plot_html_show_source_link): |
159 | 176 | build_sphinx_html(tmp_path, doctree_dir, html_dir, extra_args=[ |
160 | 177 | '-D', f'plot_html_show_source_link={plot_html_show_source_link}']) |
161 | 178 | 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