@requires_h5py
def test_open_report():
    'Test the open_report function.'
    tempdir = _TempDir()
    hdf5 = op.join(tempdir, 'report.h5')
    fig1 = _get_example_figures()[0]
    with open_report(hdf5, subjects_dir=subjects_dir) as report:
        assert (report.subjects_dir == subjects_dir)
        assert (report._fname == hdf5)
        report.add_figs_to_section(figs=fig1, captions=['evoked response'])
    assert op.exists(hdf5)
    report2 = open_report(hdf5)
    assert (report2._fname == hdf5)
    assert (report2.subjects_dir == report.subjects_dir)
    assert (report2.html == report.html)
    assert (report2.__getstate__() == report.__getstate__())
    assert ('_fname' not in report2.__getstate__())
    pytest.raises(ValueError, open_report, hdf5, foo='bar')
    pytest.raises(ValueError, open_report, hdf5, subjects_dir='foo')
    open_report(hdf5, subjects_dir=subjects_dir)
    with pytest.raises(ZeroDivisionError):
        with open_report(hdf5, subjects_dir=subjects_dir) as report:
            (1 / 0)
Test the open_report function.
@requires_h5py
def test_open_report():
    
    tempdir = _TempDir()
    hdf5 = op.join(tempdir, 'report.h5')
    fig1 = _get_example_figures()[0]
    with open_report(hdf5, subjects_dir=subjects_dir) as report:
        assert (report.subjects_dir == subjects_dir)
        assert (report._fname == hdf5)
        report.add_figs_to_section(figs=fig1, captions=['evoked response'])
    assert op.exists(hdf5)
    report2 = open_report(hdf5)
    assert (report2._fname == hdf5)
    assert (report2.subjects_dir == report.subjects_dir)
    assert (report2.html == report.html)
    assert (report2.__getstate__() == report.__getstate__())
    assert ('_fname' not in report2.__getstate__())
    pytest.raises(ValueError, open_report, hdf5, foo='bar')
    pytest.raises(ValueError, open_report, hdf5, subjects_dir='foo')
    open_report(hdf5, subjects_dir=subjects_dir)
    with pytest.raises(ZeroDivisionError):
        with open_report(hdf5, subjects_dir=subjects_dir) as report:
            (1 / 0)