MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_srcset_version

Function test_srcset_version

lib/matplotlib/tests/test_sphinxext.py:232–271  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

230
231
232def test_srcset_version(tmp_path):
233 shutil.copytree(tinypages, tmp_path, dirs_exist_ok=True,
234 ignore=shutil.ignore_patterns('_build', 'doctrees',
235 'plot_directive'))
236 html_dir = tmp_path / '_build' / 'html'
237 img_dir = html_dir / '_images'
238 doctree_dir = tmp_path / 'doctrees'
239
240 build_sphinx_html(tmp_path, doctree_dir, html_dir,
241 extra_args=['-D', 'plot_srcset=2x'])
242
243 def plot_file(num, suff=''):
244 return img_dir / f'some_plots-{num}{suff}.png'
245
246 # check some-plots
247 for ind in [1, 2, 3, 5, 7, 11, 13, 15, 17]:
248 assert plot_file(ind).exists()
249 assert plot_file(ind, suff='.2x').exists()
250
251 assert (img_dir / 'nestedpage-index-1.png').exists()
252 assert (img_dir / 'nestedpage-index-1.2x.png').exists()
253 assert (img_dir / 'nestedpage-index-2.png').exists()
254 assert (img_dir / 'nestedpage-index-2.2x.png').exists()
255 assert (img_dir / 'nestedpage2-index-1.png').exists()
256 assert (img_dir / 'nestedpage2-index-1.2x.png').exists()
257 assert (img_dir / 'nestedpage2-index-2.png').exists()
258 assert (img_dir / 'nestedpage2-index-2.2x.png').exists()
259
260 # Check html for srcset
261
262 assert ('srcset="_images/some_plots-1.png, _images/some_plots-1.2x.png 2.00x"'
263 in (html_dir / 'some_plots.html').read_text(encoding='utf-8'))
264
265 st = ('srcset="../_images/nestedpage-index-1.png, '
266 '../_images/nestedpage-index-1.2x.png 2.00x"')
267 assert st in (html_dir / 'nestedpage/index.html').read_text(encoding='utf-8')
268
269 st = ('srcset="../_images/nestedpage2-index-2.png, '
270 '../_images/nestedpage2-index-2.2x.png 2.00x"')
271 assert st in (html_dir / 'nestedpage2/index.html').read_text(encoding='utf-8')

Callers

nothing calls this directly

Calls 2

build_sphinx_htmlFunction · 0.85
plot_fileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…