File: test_scraper.py

package info (click to toggle)
python-mne 1.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 100,172 kB
  • sloc: python: 166,349; pascal: 3,602; javascript: 1,472; sh: 334; makefile: 236
file content (28 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Authors: Eric Larson <larson.eric.d@gmail.com>
#
# License: Simplified BSD

import os.path as op
import pytest
import mne
from mne.utils import requires_version


@pytest.mark.pgtest
@requires_version('sphinx_gallery')
def test_qt_scraper(raw, pg_backend, tmp_path):
    """Test sphinx-gallery scraping of the browser."""
    # make sure there is only one to scrape from old tests
    fig = raw.plot(group_by='selection')
    (tmp_path / '_images').mkdir()
    image_paths = [
        str(tmp_path / '_images' / 'temp_{ii}.png') for ii in range(2)]
    gallery_conf = dict(builder_name='html', src_dir=str(tmp_path))
    block_vars = dict(
        example_globals=dict(fig=fig),
        image_path_iterator=iter(image_paths))
    assert not any(op.isfile(image_path) for image_path in image_paths)
    assert not getattr(fig, '_scraped', False)
    mne.viz._scraper._MNEQtBrowserScraper()(None, block_vars, gallery_conf)
    assert all(op.isfile(image_path) for image_path in image_paths)
    assert fig._scraped