Here are the examples of the python api bokeh.document.document.Document taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
91 Examples
3
View Source File : viewable.py
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holoviz
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holoviz
def _render_model(self, doc=None, comm=None):
if doc is None:
doc = _Document()
if comm is None:
comm = state._comm_manager.get_server_comm()
model = self.get_root(doc, comm)
if config.embed:
embed_state(self, model, doc,
json=config.embed_json,
json_prefix=config.embed_json_prefix,
save_path=config.embed_save_path,
load_path=config.embed_load_path,
progress=False)
else:
add_to_doc(model, doc)
return model
def _init_params(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_hold(self, policy):
d = document.Document()
assert d._hold == None
assert d._held_events == []
d.hold(policy)
assert d._hold == policy
def test_hold_bad_policy(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_hold_bad_policy(self):
d = document.Document()
with pytest.raises(ValueError):
d.hold("junk")
@pytest.mark.parametrize('first,second', [('combine', 'collect'), ('collect', 'combine')])
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_unhold(self, policy):
d = document.Document()
assert d._hold == None
assert d._held_events == []
d.hold(policy)
assert d._hold == policy
d.unhold()
assert d._hold == None
@patch("bokeh.document.document.Document._trigger_on_change")
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_unhold_triggers_events(self, mock_trigger):
d = document.Document()
d.hold('collect')
d._held_events = [1,2,3]
d.unhold()
assert mock_trigger.call_count == 3
assert mock_trigger.call_args[0] == (3,)
assert mock_trigger.call_args[1] == {}
extra = []
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_basic(self):
d = document.Document()
assert not d.roots
class FakeMod(object):
__name__ = 'junkjunkjunk'
mod = FakeMod()
import sys
assert 'junkjunkjunk' not in sys.modules
sys.modules['junkjunkjunk'] = mod
d._modules.append(mod)
assert 'junkjunkjunk' in sys.modules
d.delete_modules()
assert 'junkjunkjunk' not in sys.modules
assert d._modules is None
def test_extra_referrer_error(self, caplog):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_default_template_vars(self):
d = document.Document()
assert not d.roots
assert d.template_variables == {}
def test_add_roots(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_add_roots(self):
d = document.Document()
assert not d.roots
d.add_root(AnotherModelInTestDocument())
assert len(d.roots) == 1
assert next(iter(d.roots)).document == d
def test_roots_preserves_insertion_order(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_roots_preserves_insertion_order(self):
d = document.Document()
assert not d.roots
roots = [
AnotherModelInTestDocument(),
AnotherModelInTestDocument(),
AnotherModelInTestDocument(),
]
for r in roots:
d.add_root(r)
assert len(d.roots) == 3
assert type(d.roots) is list
roots_iter = iter(d.roots)
assert next(roots_iter) is roots[0]
assert next(roots_iter) is roots[1]
assert next(roots_iter) is roots[2]
def test_set_title(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_set_title(self):
d = document.Document()
assert d.title == document.DEFAULT_TITLE
d.title = "Foo"
assert d.title == "Foo"
def test_all_models(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_all_models(self):
d = document.Document()
assert not d.roots
assert len(d._all_models) == 0
m = SomeModelInTestDocument()
m2 = AnotherModelInTestDocument()
m.child = m2
d.add_root(m)
assert len(d.roots) == 1
assert len(d._all_models) == 2
m.child = None
assert len(d._all_models) == 1
m.child = m2
assert len(d._all_models) == 2
d.remove_root(m)
assert len(d._all_models) == 0
def test_get_model_by_id(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_get_model_by_id(self):
d = document.Document()
assert not d.roots
assert len(d._all_models) == 0
m = SomeModelInTestDocument()
m2 = AnotherModelInTestDocument()
m.child = m2
d.add_root(m)
assert len(d.roots) == 1
assert len(d._all_models) == 2
assert d.get_model_by_id(m.id) == m
assert d.get_model_by_id(m2.id) == m2
assert d.get_model_by_id("not a valid ID") is None
def test_get_model_by_name(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_get_model_by_name(self):
d = document.Document()
assert not d.roots
assert len(d._all_models) == 0
m = SomeModelInTestDocument(name="foo")
m2 = AnotherModelInTestDocument(name="bar")
m.child = m2
d.add_root(m)
assert len(d.roots) == 1
assert len(d._all_models) == 2
assert len(d._all_models_by_name._dict) == 2
assert d.get_model_by_name(m.name) == m
assert d.get_model_by_name(m2.name) == m2
assert d.get_model_by_name("not a valid name") is None
def test_get_model_by_changed_name(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_get_model_by_changed_name(self):
d = document.Document()
m = SomeModelInTestDocument(name="foo")
d.add_root(m)
assert d.get_model_by_name("foo") == m
m.name = "bar"
assert d.get_model_by_name("foo") == None
assert d.get_model_by_name("bar") == m
def test_get_model_by_changed_from_none_name(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_get_model_by_changed_from_none_name(self):
d = document.Document()
m = SomeModelInTestDocument(name=None)
d.add_root(m)
assert d.get_model_by_name("bar") == None
m.name = "bar"
assert d.get_model_by_name("bar") == m
def test_get_model_by_changed_to_none_name(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_get_model_by_changed_to_none_name(self):
d = document.Document()
m = SomeModelInTestDocument(name="bar")
d.add_root(m)
assert d.get_model_by_name("bar") == m
m.name = None
assert d.get_model_by_name("bar") == None
def test_can_get_name_overriding_model_by_name(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_can_get_name_overriding_model_by_name(self):
d = document.Document()
m = ModelThatOverridesName(name="foo")
d.add_root(m)
assert d.get_model_by_name("foo") == m
m.name = "bar"
assert d.get_model_by_name("bar") == m
def test_cannot_get_model_with_duplicate_name(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_cannot_get_model_with_duplicate_name(self):
d = document.Document()
m = SomeModelInTestDocument(name="foo")
m2 = SomeModelInTestDocument(name="foo")
d.add_root(m)
d.add_root(m2)
got_error = False
try:
d.get_model_by_name("foo")
except ValueError as e:
got_error = True
assert 'Found more than one' in repr(e)
assert got_error
d.remove_root(m)
assert d.get_model_by_name("foo") == m2
def test_select(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_is_single_string_selector(self):
d = document.Document()
# this is an implementation detail but just ensuring it works
assert d._is_single_string_selector(dict(foo='c'), 'foo')
assert d._is_single_string_selector(dict(foo=u'c'), 'foo')
assert not d._is_single_string_selector(dict(foo='c', bar='d'), 'foo')
assert not d._is_single_string_selector(dict(foo=42), 'foo')
def test_all_models_with_multiple_references(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_change_notification_removal(self):
d = document.Document()
assert not d.roots
m = AnotherModelInTestDocument()
d.add_root(m)
assert len(d.roots) == 1
assert m.bar == 1
events = []
def listener(event):
events.append(event)
d.on_change(listener)
m.bar = 42
assert len(events) == 1
assert events[0].new == 42
d.remove_on_change(listener)
m.bar = 43
assert len(events) == 1
def test_notification_of_roots(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_notification_of_title(self):
d = document.Document()
assert not d.roots
assert d.title == document.DEFAULT_TITLE
events = []
def listener(event):
events.append(event)
d.on_change(listener)
d.title = "Foo"
assert d.title == "Foo"
assert len(events) == 1
assert isinstance(events[0], TitleChangedEvent)
assert events[0].document is d
assert events[0].title == "Foo"
def test_add_remove_periodic_callback(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_periodic_callback_gets_curdoc(self):
d = document.Document()
assert curdoc() is not d
curdoc_from_cb = []
def cb():
curdoc_from_cb.append(curdoc())
callback_obj = d.add_periodic_callback(cb, 1)
callback_obj.callback()
assert len(curdoc_from_cb) == 1
assert curdoc_from_cb[0] is d
def test_timeout_callback_gets_curdoc(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_timeout_callback_gets_curdoc(self):
d = document.Document()
assert curdoc() is not d
curdoc_from_cb = []
def cb():
curdoc_from_cb.append(curdoc())
callback_obj = d.add_timeout_callback(cb, 1)
callback_obj.callback()
assert len(curdoc_from_cb) == 1
assert curdoc_from_cb[0] is d
def test_next_tick_callback_gets_curdoc(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_next_tick_callback_gets_curdoc(self):
d = document.Document()
assert curdoc() is not d
curdoc_from_cb = []
def cb():
curdoc_from_cb.append(curdoc())
callback_obj = d.add_next_tick_callback(cb)
callback_obj.callback()
assert len(curdoc_from_cb) == 1
assert curdoc_from_cb[0] is d
def test_model_callback_gets_curdoc(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_model_callback_gets_curdoc(self):
d = document.Document()
m = AnotherModelInTestDocument(bar=42)
d.add_root(m)
assert curdoc() is not d
curdoc_from_cb = []
def cb(attr, old, new):
curdoc_from_cb.append(curdoc())
m.on_change('bar', cb)
m.bar = 43
assert len(curdoc_from_cb) == 1
assert curdoc_from_cb[0] is d
def test_clear(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_clear(self):
d = document.Document()
assert not d.roots
assert d.title == document.DEFAULT_TITLE
d.add_root(AnotherModelInTestDocument())
d.add_root(AnotherModelInTestDocument())
d.title = "Foo"
assert len(d.roots) == 2
assert d.title == "Foo"
d.clear()
assert not d.roots
assert not d._all_models
assert d.title == "Foo" # do not reset title
def test_serialization_one_model(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_serialization_one_model(self):
d = document.Document()
assert not d.roots
assert len(d._all_models) == 0
root1 = SomeModelInTestDocument()
d.add_root(root1)
d.title = "Foo"
json = d.to_json_string()
copy = document.Document.from_json_string(json)
assert len(copy.roots) == 1
assert copy.title == "Foo"
def test_serialization_more_models(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_serialization_has_version(self):
from bokeh import __version__
d = document.Document()
json = d.to_json()
assert json['version'] == __version__
def test_patch_integer_property(self):
3
View Source File : test_document.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_scatter(self):
from bokeh.io.doc import set_curdoc
from bokeh.plotting import figure
import numpy as np
d = document.Document()
set_curdoc(d)
assert not d.roots
assert len(d._all_models) == 0
p1 = figure(tools=[])
N = 10
x = np.linspace(0, 4 * np.pi, N)
y = np.sin(x)
p1.scatter(x, y, color="#FF00FF", nonselection_fill_color="#FFFF00", nonselection_fill_alpha=1)
# figure does not automatically add itself to the document
d.add_root(p1)
assert len(d.roots) == 1
def test_event_handles_new_callbacks_in_event_callback(self):
3
View Source File : test_locking.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_next_tick_callback_works():
d = locking.UnlockedDocumentProxy(Document())
assert curdoc() is not d
curdoc_from_cb = []
def cb():
curdoc_from_cb.append(curdoc())
callback_obj = d.add_next_tick_callback(cb)
callback_obj.callback()
assert len(curdoc_from_cb) == 1
assert curdoc_from_cb[0] is d._doc
def cb2(): pass
callback_obj = d.add_next_tick_callback(cb2)
d.remove_next_tick_callback(callback_obj)
def test_other_attrs_raise():
3
View Source File : test_locking.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_other_attrs_raise():
d = locking.UnlockedDocumentProxy(Document())
assert curdoc() is not d
for attr in (set(dir(d._doc)) - set(dir(d))) | {'foo'}:
with pytest.raises(RuntimeError) as e:
getattr(d, attr)
assert e.value.args[0] == locking.UNSAFE_DOC_ATTR_USAGE_MSG
def test_without_document_lock():
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_error_on_mixed_list(self):
p = Model()
d = Document()
orig_theme = d.theme
with pytest.raises(ValueError) as e:
with beu.OutputDocumentFor([p, d]):
pass
assert str(e).endswith(_ODFERR)
assert d.theme is orig_theme
@pytest.mark.parametrize('v', [10, -0,3, "foo", True])
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_with_doc_in_child_raises_error(self):
doc = Document()
p1 = Model()
p2 = SomeModelInTestObjects(child=Model())
doc.add_root(p2.child)
assert p1.document is None
assert p2.document is None
assert p2.child.document is doc
with pytest.raises(RuntimeError) as e:
with beu.OutputDocumentFor([p1, p2]):
pass
assert "already in a doc" in str(e)
@patch('bokeh.document.document.check_integrity')
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]):
assert p.document is d
assert d.theme is orig_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_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]):
assert p1.document is d
assert p2.document is d
assert d.theme is orig_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):
assert p1.document is not d
assert p2.document is not d
assert p1.document is p2.document
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_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]):
assert p1.document is not d
assert p2.document is d
assert p1.document.theme is orig_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_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=Theme(json={})):
assert p.document is d
assert d.theme is not orig_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_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=Theme(json={})):
assert p1.document is d
assert p2.document is d
assert d.theme is not orig_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=Theme(json={})):
assert p1.document is not d
assert p2.document is not d
assert p1.document is p2.document
assert p2.document.theme is not orig_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=Theme(json={})):
assert p1.document is not d
assert p2.document is d
assert p1.document.theme is not orig_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_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_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_passing_model(self):
p1 = Model()
d = Document()
d.add_root(p1)
docs_json, render_items = beu.standalone_docs_json_and_render_items([p1])
doc = list(docs_json.values())[0]
assert doc['title'] == "Bokeh Application"
assert doc['version'] == __version__
assert len(doc['roots']['root_ids']) == 1
assert len(doc['roots']['references']) == 1
assert doc['roots']['references'] == [{'attributes': {}, 'id': str(p1.id), 'type': 'Model'}]
assert len(render_items) == 1
def test_passing_doc(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_passing_doc(self):
p1 = Model()
d = Document()
d.add_root(p1)
docs_json, render_items = beu.standalone_docs_json_and_render_items([d])
doc = list(docs_json.values())[0]
assert doc['title'] == "Bokeh Application"
assert doc['version'] == __version__
assert len(doc['roots']['root_ids']) == 1
assert len(doc['roots']['references']) == 1
assert doc['roots']['references'] == [{'attributes': {}, 'id': str(p1.id), 'type': 'Model'}]
assert len(render_items) == 1
def test_exception_for_missing_doc(self):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_log_warning_if_python_property_callback(self, caplog):
d = Document()
m1 = EmbedTestUtilModel()
c1 = _GoodPropertyCallback()
d.add_root(m1)
m1.on_change('name', c1)
assert len(m1._callbacks) != 0
with caplog.at_level(logging.WARN):
beu.standalone_docs_json_and_render_items(m1)
assert len(caplog.records) == 1
assert caplog.text != ''
def test_log_warning_if_python_event_callback(self, caplog):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_log_warning_if_python_event_callback(self, caplog):
d = Document()
m1 = EmbedTestUtilModel()
c1 = _GoodEventCallback()
d.add_root(m1)
m1.on_event(Tap, c1)
assert len(m1._event_callbacks) != 0
with caplog.at_level(logging.WARN):
beu.standalone_docs_json_and_render_items(m1)
assert len(caplog.records) == 1
assert caplog.text != ''
def test_suppress_warnings(self, caplog):
3
View Source File : test_util.py
License : MIT License
Project Creator : rthorst
License : MIT License
Project Creator : rthorst
def test_suppress_warnings(self, caplog):
d = Document()
m1 = EmbedTestUtilModel()
c1 = _GoodPropertyCallback()
c2 = _GoodEventCallback()
d.add_root(m1)
m1.on_change('name', c1)
assert len(m1._callbacks) != 0
m1.on_event(Tap, c2)
assert len(m1._event_callbacks) != 0
with caplog.at_level(logging.WARN):
beu.standalone_docs_json_and_render_items(m1, suppress_callback_warning=True)
assert len(caplog.records) == 0
assert caplog.text == ''
class Test_standalone_docs_json(object):
See More Examples