@testing.requires_testing_data
@requires_mayavi
@traits_test
def test_render_add_sections():
    'Test adding figures/images to section.'
    tempdir = _TempDir()
    report = Report(subjects_dir=subjects_dir)
    fig = plt.plot([1, 2], [1, 2])[0].figure
    report.add_figs_to_section(figs=fig, captions=['evoked response'], scale=1.2, image_format='svg')
    pytest.raises(ValueError, report.add_figs_to_section, figs=[fig, fig], captions='H')
    pytest.raises(ValueError, report.add_figs_to_section, figs=fig, captions=['foo'], scale=0, image_format='svg')
    pytest.raises(ValueError, report.add_figs_to_section, figs=fig, captions=['foo'], scale=1e-10, image_format='svg')
    fig = plt.plot([1, 2], [1, 2])[0].figure
    img_fname = op.join(tempdir, 'testimage.png')
    fig.savefig(img_fname)
    report.add_images_to_section(fnames=[img_fname], captions=['evoked response'])
    report.add_images_to_section(fnames=[img_fname], captions=['evoked response'])
    pytest.raises(ValueError, report.add_images_to_section, fnames=[img_fname, img_fname], captions='H')
    pytest.raises(ValueError, report.add_images_to_section, fnames=['foobar.xxx'], captions='H')
    evoked = read_evokeds(evoked_fname, condition='Left Auditory', baseline=((- 0.2), 0.0))
    fig = plot_alignment(evoked.info, trans_fname, subject='sample', subjects_dir=subjects_dir)
    report.add_figs_to_section(figs=fig, captions='random image', scale=1.2)
    assert repr(report)
Test adding figures/images to section.
@testing.requires_testing_data
@requires_mayavi
@traits_test
def test_render_add_sections():
    
    tempdir = _TempDir()
    report = Report(subjects_dir=subjects_dir)
    fig = plt.plot([1, 2], [1, 2])[0].figure
    report.add_figs_to_section(figs=fig, captions=['evoked response'], scale=1.2, image_format='svg')
    pytest.raises(ValueError, report.add_figs_to_section, figs=[fig, fig], captions='H')
    pytest.raises(ValueError, report.add_figs_to_section, figs=fig, captions=['foo'], scale=0, image_format='svg')
    pytest.raises(ValueError, report.add_figs_to_section, figs=fig, captions=['foo'], scale=1e-10, image_format='svg')
    fig = plt.plot([1, 2], [1, 2])[0].figure
    img_fname = op.join(tempdir, 'testimage.png')
    fig.savefig(img_fname)
    report.add_images_to_section(fnames=[img_fname], captions=['evoked response'])
    report.add_images_to_section(fnames=[img_fname], captions=['evoked response'])
    pytest.raises(ValueError, report.add_images_to_section, fnames=[img_fname, img_fname], captions='H')
    pytest.raises(ValueError, report.add_images_to_section, fnames=['foobar.xxx'], captions='H')
    evoked = read_evokeds(evoked_fname, condition='Left Auditory', baseline=((- 0.2), 0.0))
    fig = plot_alignment(evoked.info, trans_fname, subject='sample', subjects_dir=subjects_dir)
    report.add_figs_to_section(figs=fig, captions='random image', scale=1.2)
    assert repr(report)