Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify some Sphinx tests #30090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions lib/matplotlib/tests/test_sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
extra_args = [] if extra_args is None else extra_args
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
'-d', str(doctree_dir), str(source_dir), str(html_dir), *extra_args]
# On CI, gcov emits warnings (due to agg headers being included with the
# same name in multiple extension modules -- but we don't care about their
# coverage anyways); hide them using GCOV_ERROR_FILE.
proc = subprocess_run_for_testing(
cmd, capture_output=True, text=True,
env={**os.environ, "MPLBACKEND": ""})
env={**os.environ, "MPLBACKEND": "", "GCOV_ERROR_FILE": os.devnull}
)
out = proc.stdout
err = proc.stderr

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

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


def test_srcset_version(tmp_path):
shutil.copytree(tinypages, tmp_path, dirs_exist_ok=True)
html_dir = tmp_path / '_build' / 'html'
img_dir = html_dir / '_images'
doctree_dir = tmp_path / 'doctrees'

build_sphinx_html(tmp_path, doctree_dir, html_dir, extra_args=[
'-D', 'plot_srcset=2x'])
build_sphinx_html(tinypages, doctree_dir, html_dir,
extra_args=['-D', 'plot_srcset=2x'])

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