(tmp_path)
| 230 | |
| 231 | |
| 232 | def 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') |
nothing calls this directly
no test coverage detected
searching dependent graphs…