def test_show_doesnt_duplicate_if_already_there(m): curstate().reset() assert curstate().document.roots == [] p = Plot() bis.show(p) assert curstate().document.roots == [p] bis.show(p) assert curstate().document.roots == [p]
def test_show_with_default_args(mock__show_with_state): curstate().reset() default_kwargs = dict(browser=None, new="tab", notebook_handle=False) p = Plot() bis.show(p, **default_kwargs) assert mock__show_with_state.call_count == 1 assert mock__show_with_state.call_args[0] == (p, curstate(), None, "tab") assert mock__show_with_state.call_args[1] == {'notebook_handle': False} assert p in curdoc().roots
def test_show_with_explicit_args(mock__show_with_state): curstate().reset() kwargs = dict(browser="browser", new="new", notebook_handle=True) p = Plot() bis.show(p, **kwargs) assert mock__show_with_state.call_count == 1 assert mock__show_with_state.call_args[0] == (p, curstate(), "browser", "new") assert mock__show_with_state.call_args[1] == {'notebook_handle': True} assert p in curdoc().roots
def test_show_doesn_not_adds_obj_to_curdoc(m) -> None: curstate().reset() assert curstate().document.roots == [] p = Plot() bis.show(p) assert curstate().document.roots == [] p = Plot() bis.show(p) assert curstate().document.roots == []
def test_show_doesn_not_adds_obj_to_curdoc(m): curstate().reset() assert curstate().document.roots == [] p = Plot() bis.show(p) assert curstate().document.roots == [] p = Plot() bis.show(p) assert curstate().document.roots == []
def test_show_with_app(mock_run_notebook_hook): curstate().reset() app = Application() output_notebook() bis.show(app, notebook_url="baz") assert curstate().notebook_type == "jupyter" assert mock_run_notebook_hook.call_count == 1 assert mock_run_notebook_hook.call_args[0][0] == curstate().notebook_type assert mock_run_notebook_hook.call_args[0][1:] == ("app", app, curstate(), "baz") assert mock_run_notebook_hook.call_args[1] == {}
def test_show_adds_obj_to_document_if_not_already_there(m): curstate().reset() assert curstate().document.roots == [] p = Plot() bis.show(p) assert p in curstate().document.roots
def test_show_with_bad_object(obj): with pytest.raises(ValueError): bis.show(obj)
def main_vis(fig): show(fig)