diff --git a/brainrender/render.py b/brainrender/render.py index b2dcc0d1..a7d91408 100644 --- a/brainrender/render.py +++ b/brainrender/render.py @@ -289,6 +289,7 @@ def export(self, savepath): """ logger.debug(f"Exporting scene to {savepath}") _backend = self.backend + _default_backend = vsettings.default_backend if not self.is_rendered: self.render(interactive=False) @@ -302,9 +303,8 @@ def export(self, savepath): # Create new plotter and save to file plt = Plotter() - plt.add(self.clean_renderables, render=False) + plt.add(self.clean_renderables).render() plt = plt.show(interactive=False) - plt.camera[-2] = -1 with open(path, "w") as fp: fp.write(plt.get_snapshot()) @@ -314,7 +314,7 @@ def export(self, savepath): ) # Reset settings - vsettings.notebookBackend = None + vsettings.default_backend = _default_backend self.backend = _backend return str(path) diff --git a/tests/test_export_html.py b/tests/test_export_html.py index 4ac5cc4e..70ca54b5 100644 --- a/tests/test_export_html.py +++ b/tests/test_export_html.py @@ -5,15 +5,18 @@ from brainrender import Scene -@pytest.mark.local -def test_export_for_web(): +@pytest.fixture +def scene(): + """Provide a scene with a brain region""" s = Scene(title="BR") - th = s.add_brain_region("TH") - s.add_label(th, "TH") + return s - path = s.export("test.html") + +def test_export_for_web(scene): + """Check that exporting to html creates the expected file""" + path = scene.export("test.html") assert path == "test.html" path = Path(path) @@ -21,5 +24,8 @@ def test_export_for_web(): path.unlink() + +def test_export_for_web_raises(scene): + """Check that exporting with invalid file extention raises ValueError""" with pytest.raises(ValueError): - path = s.export("test.py") + scene.export("test.py")