Beispiel #1
0
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]
Beispiel #2
0
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]
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
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 == []
Beispiel #6
0
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
Beispiel #7
0
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
Beispiel #8
0
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 == []
Beispiel #9
0
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] == {}
Beispiel #10
0
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] == {}
Beispiel #11
0
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
Beispiel #12
0
def test_show_with_bad_object(obj):
    with pytest.raises(ValueError):
        bis.show(obj)
Beispiel #13
0
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
Beispiel #14
0
def test_show_with_bad_object(obj):
    with pytest.raises(ValueError):
        bis.show(obj)
Beispiel #15
0
def main_vis(fig):
    show(fig)