Skip to content

Commit

Permalink
[FIX] Make report context manager stop swallowing exceptions (#6614)
Browse files Browse the repository at this point in the history
Make report context manager stop swallowing exceptions
  • Loading branch information
wmvanvliet authored Jul 30, 2019
1 parent 3acb8dc commit cc836c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Bug

- Fix :func:`mne.io.read_raw_brainvision` not handling ``Event`` markers created by PyCorder correctly by `Richard Höchenberger`_

- Fix :class:`mne.Report` silently suppressing exceptions when used as a context manager by `Marijn van Vliet`_

API
~~~

Expand Down
1 change: 0 additions & 1 deletion mne/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,6 @@ def __exit__(self, type, value, traceback):
"""Save the report when leaving the context block."""
if self._fname is not None:
self.save(self._fname, open_browser=False, overwrite=True)
return self

@verbose
def _render_toc(self, verbose=None):
Expand Down
5 changes: 5 additions & 0 deletions mne/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ def test_open_report():
pytest.raises(ValueError, open_report, hdf5, subjects_dir='foo')
open_report(hdf5, subjects_dir=subjects_dir) # This should work

# Check that the context manager doesn't swallow exceptions
with pytest.raises(ZeroDivisionError):
with open_report(hdf5, subjects_dir=subjects_dir) as report:
1 / 0


def test_remove():
"""Test removing figures from a report."""
Expand Down

0 comments on commit cc836c2

Please sign in to comment.