當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。