From ef58852d9a9db7eae818b832c87d41f78997d4ff Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Wed, 19 Jun 2024 22:23:41 -0400 Subject: [PATCH 1/2] more --- nglview/tests/test_widget.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nglview/tests/test_widget.py b/nglview/tests/test_widget.py index a7ab11b5..dba952a1 100644 --- a/nglview/tests/test_widget.py +++ b/nglview/tests/test_widget.py @@ -527,7 +527,7 @@ def test_show_pymatgen(): def test_show_qcelemental(): import qcelemental as qcel - mol = qcel.models.Molecule.from_data("He 0 0 0") + mol = qcel.models.Molecule.from_data("He 0 0 0") view = nv.show_qcelemental(mol) view @@ -1026,6 +1026,7 @@ def test_write_html(mock_unset): fp = StringIO() with patch.object(embed, 'embed_snippet') as mock_embed: + mock_embed.embed_snippet.return_value = 'ok' nv.write_html(fp, [view], frame_range=(0, 3)) mock_embed.assert_called_with([tm, cm, view]) mock_unset.assert_called_with() @@ -1034,6 +1035,7 @@ def test_write_html(mock_unset): # box with patch.object(embed, 'embed_snippet') as mock_embed: + mock_embed.embed_snippet.return_value = 'ok' nv.write_html(fp, [HBox([view])], frame_range=(0, 3)) # FIXME: assertion? From a0cc4e638c37521d7e9c088f1d34dd7d0a13ff7f Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Wed, 19 Jun 2024 22:31:25 -0400 Subject: [PATCH 2/2] fix --- nglview/tests/test_widget.py | 10 +++++----- nglview/widget.py | 5 +---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/nglview/tests/test_widget.py b/nglview/tests/test_widget.py index dba952a1..8cb5b893 100644 --- a/nglview/tests/test_widget.py +++ b/nglview/tests/test_widget.py @@ -1025,17 +1025,17 @@ def test_write_html(mock_unset): display(view) fp = StringIO() - with patch.object(embed, 'embed_snippet') as mock_embed: - mock_embed.embed_snippet.return_value = 'ok' + with patch.object(embed, 'embed_snippet') as mock_embed_snippet: + mock_embed_snippet.return_value = 'ok' nv.write_html(fp, [view], frame_range=(0, 3)) - mock_embed.assert_called_with([tm, cm, view]) + mock_embed_snippet.assert_called_with([tm, cm, view]) mock_unset.assert_called_with() assert len(view._ngl_coordinate_resource[0]) == 3 assert len(view._ngl_coordinate_resource[1]) == 3 # box - with patch.object(embed, 'embed_snippet') as mock_embed: - mock_embed.embed_snippet.return_value = 'ok' + with patch.object(embed, 'embed_snippet') as mock_embed_snippet: + mock_embed_snippet.return_value = 'ok' nv.write_html(fp, [HBox([view])], frame_range=(0, 3)) # FIXME: assertion? diff --git a/nglview/widget.py b/nglview/widget.py index 4e3273a7..b9a3c954 100644 --- a/nglview/widget.py +++ b/nglview/widget.py @@ -7,7 +7,7 @@ from logging import getLogger import ipywidgets as widgets -import ipywidgets.embed +from ipywidgets import embed import numpy as np from IPython.display import display from ipywidgets import (Image, Box, DOMWidget, HBox, VBox, IntSlider, Output, Play, Widget, @@ -85,9 +85,6 @@ def write_html(fp, views, frame_range=None): >>> nglview.write_html('index.html', [view], frame_range=(0, 5)) # doctest: +SKIP """ views = isinstance(views, DOMWidget) and [views] or views - embed = ipywidgets.embed - color = None - theme = None for _, v in _INIT_VIEWS.items(): views.insert(0, v)