Here are the examples of the python api bokeh.embed.util.FromCurdoc taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
9 Examples
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_single_model_with_document(self):
# should use existing doc in with-block
p = Model()
d = Document()
orig_theme = d.theme
d.add_root(p)
with beu.OutputDocumentFor([p], apply_theme=beu.FromCurdoc):
assert p.document is d
assert d.theme is curdoc().theme
assert p.document is d
assert d.theme is orig_theme
def test_single_model_with_no_document(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_single_model_with_no_document(self):
p = Model()
assert p.document is None
with beu.OutputDocumentFor([p], apply_theme=beu.FromCurdoc):
assert p.document is not None
assert p.document.theme is curdoc().theme
new_doc = p.document
assert p.document is new_doc
assert p.document.theme is not curdoc().theme
def test_list_of_model_with_no_documents(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_list_of_model_with_no_documents(self):
# should create new (permanent) doc for inputs
p1 = Model()
p2 = Model()
assert p1.document is None
assert p2.document is None
with beu.OutputDocumentFor([p1, p2], apply_theme=beu.FromCurdoc):
assert p1.document is not None
assert p2.document is not None
assert p1.document is p2.document
new_doc = p1.document
assert p1.document.theme is curdoc().theme
assert p1.document is new_doc
assert p2.document is new_doc
assert p1.document is p2.document
# should restore to default theme after with-block
assert p1.document.theme is not curdoc().theme
def test_list_of_model_same_as_roots(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_list_of_model_same_as_roots(self):
# should use existing doc in with-block
p1 = Model()
p2 = Model()
d = Document()
orig_theme = d.theme
d.add_root(p1)
d.add_root(p2)
with beu.OutputDocumentFor([p1, p2], apply_theme=beu.FromCurdoc):
assert p1.document is d
assert p2.document is d
assert d.theme is curdoc().theme
assert p1.document is d
assert p2.document is d
assert d.theme is orig_theme
def test_list_of_model_same_as_roots_with_always_new(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_list_of_model_same_as_roots_with_always_new(self):
# should use new temp doc for everything inside with-block
p1 = Model()
p2 = Model()
d = Document()
orig_theme = d.theme
d.add_root(p1)
d.add_root(p2)
with beu.OutputDocumentFor([p1, p2], always_new=True, apply_theme=beu.FromCurdoc):
assert p1.document is not d
assert p2.document is not d
assert p1.document is p2.document
assert p2.document.theme is curdoc().theme
assert p1.document is d
assert p2.document is d
assert d.theme is orig_theme
def test_list_of_model_subset_roots(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_list_of_model_subset_roots(self):
# should use new temp doc for subset inside with-block
p1 = Model()
p2 = Model()
d = Document()
orig_theme = d.theme
d.add_root(p1)
d.add_root(p2)
with beu.OutputDocumentFor([p1], apply_theme=beu.FromCurdoc):
assert p1.document is not d
assert p2.document is d
assert p1.document.theme is curdoc().theme
assert p2.document.theme is orig_theme
assert p1.document is d
assert p2.document is d
assert d.theme is orig_theme
def test_list_of_models_different_docs(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_apply_from_curdoc(self):
t = Theme(json={})
curdoc().theme = t
d = Document()
orig = d.theme
beu._set_temp_theme(d, beu.FromCurdoc)
assert d._old_theme is orig
assert d.theme is t
class Test__unset_temp_theme(object):
0
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_type(self):
assert isinstance(beu.FromCurdoc, type)
_ODFERR = "OutputDocumentFor expects a sequence of Models"
0
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_list_of_models_different_docs(self):
# should use new temp doc for eveything inside with-block
d = Document()
orig_theme = d.theme
p1 = Model()
p2 = Model()
d.add_root(p2)
assert p1.document is None
assert p2.document is not None
with beu.OutputDocumentFor([p1, p2], apply_theme=beu.FromCurdoc):
assert p1.document is not None
assert p2.document is not None
assert p1.document is not d
assert p2.document is not d
assert p1.document == p2.document
assert p1.document.theme is curdoc().theme
assert p1.document is None
assert p2.document is not None
assert p2.document.theme is orig_theme
class Test_standalone_docs_json_and_render_items(object):