当前位置: 首页>>代码示例>>Python>>正文


Python document.Document类代码示例

本文整理汇总了Python中bokeh.document.document.Document的典型用法代码示例。如果您正苦于以下问题:Python Document类的具体用法?Python Document怎么用?Python Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_basic

 def test_basic(self):
     t = Theme(json={})
     d = Document()
     d._old_theme = t
     beu._unset_temp_theme(d)
     assert d.theme is t
     assert not hasattr(d, "_old_theme")
开发者ID:jakirkham,项目名称:bokeh,代码行数:7,代码来源:test_util.py

示例2: test_output

 def test_output(self):
     p1 = Model()
     p2 = Model()
     d = Document()
     d.add_root(p1)
     d.add_root(p2)
     out = beu.standalone_docs_json([p1, p2])
     expected = beu.standalone_docs_json_and_render_items([p1, p2])[0]
     assert list(out.values()) ==list(expected.values())
开发者ID:jakirkham,项目名称:bokeh,代码行数:9,代码来源:test_util.py

示例3: test_single_model_with_document

 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
开发者ID:jakirkham,项目名称:bokeh,代码行数:11,代码来源:test_util.py

示例4: test_with_doc_in_child_raises_error

 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)
开发者ID:jakirkham,项目名称:bokeh,代码行数:12,代码来源:test_util.py

示例5: test_passing_doc

 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
开发者ID:jakirkham,项目名称:bokeh,代码行数:12,代码来源:test_util.py

示例6: test_without_document_lock

def test_without_document_lock():
    d = Document()
    assert curdoc() is not d
    curdoc_from_cb = []
    @locking.without_document_lock
    def cb():
        curdoc_from_cb.append(curdoc())
    callback_obj = d.add_next_tick_callback(cb)
    callback_obj.callback()
    assert callback_obj.callback.nolock == True
    assert len(curdoc_from_cb) == 1
    assert curdoc_from_cb[0]._doc is d
    assert isinstance(curdoc_from_cb[0], locking.UnlockedDocumentProxy)
开发者ID:jakirkham,项目名称:bokeh,代码行数:13,代码来源:test_locking.py

示例7: test_top_level_same_doc

    def test_top_level_same_doc(self):
        d = Document()
        p1 = Model()
        p2 = Model()
        d.add_root(p1)
        d.add_root(p2)
        beu._create_temp_doc([p1, p2])
        assert isinstance(p1.document, Document)
        assert p1.document is not d
        assert isinstance(p2.document, Document)
        assert p2.document is not d

        assert p2.document == p1.document
开发者ID:jakirkham,项目名称:bokeh,代码行数:13,代码来源:test_util.py

示例8: test_delgation

 def test_delgation(self, mock_sdjari):
     p1 = Model()
     p2 = Model()
     d = Document()
     d.add_root(p1)
     d.add_root(p2)
     # ignore error unpacking None mock result, just checking to see that
     # standalone_docs_json_and_render_items is called as expected
     try:
         beu.standalone_docs_json([p1, p2])
     except ValueError:
         pass
     mock_sdjari.assert_called_once_with([p1, p2])
开发者ID:jakirkham,项目名称:bokeh,代码行数:13,代码来源:test_util.py

示例9: test_with_events

    def test_with_events(self, mock_comms):
        mock_comm = MagicMock()
        mock_send = MagicMock(return_value="junk")
        mock_comm.send = mock_send
        mock_comms.return_value = mock_comm

        d = Document()

        handle = binb.CommsHandle("comms", d)
        d.title = "foo"
        binb.push_notebook(d, None, handle)
        assert mock_comms.call_count > 0
        assert mock_send.call_count == 3 # sends header, metadata, then content
        assert json.loads(mock_send.call_args[0][0]) == {u"events": [{u"kind": u"TitleChanged", u"title": u"foo"}], u"references": []}
        assert mock_send.call_args[1] == {}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:15,代码来源:test_notebook.py

示例10: test_list_of_model_same_as_roots

 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
开发者ID:jakirkham,项目名称:bokeh,代码行数:15,代码来源:test_util.py

示例11: test_child_docs

    def test_child_docs(self):
        d = Document()
        p1 = Model()
        p2 = SomeModelInTestObjects(child=Model())
        d.add_root(p2.child)
        beu._create_temp_doc([p1, p2])

        assert isinstance(p1.document, Document)
        assert p1.document is not d
        assert isinstance(p2.document, Document)
        assert p2.document is not d
        assert isinstance(p2.child.document, Document)
        assert p2.child.document is not d

        assert p2.document == p1.document
        assert p2.document == p2.child.document
开发者ID:jakirkham,项目名称:bokeh,代码行数:16,代码来源:test_util.py

示例12: test_list_of_model_same_as_roots_with_always_new

 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
开发者ID:jakirkham,项目名称:bokeh,代码行数:16,代码来源:test_util.py

示例13: test_list_of_model_subset_roots

 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
开发者ID:jakirkham,项目名称:bokeh,代码行数:16,代码来源:test_util.py

示例14: test_suppress_warnings

    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 == ''
开发者ID:jakirkham,项目名称:bokeh,代码行数:17,代码来源:test_util.py

示例15: test_list_of_models_different_docs

 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
开发者ID:jakirkham,项目名称:bokeh,代码行数:19,代码来源:test_util.py


注:本文中的bokeh.document.document.Document类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。