1 2
from collections import OrderedDict
2

3 2
from bokeh.models import Div
4

5 2
from panel.io.notebook import render_mimebundle
6 2
from panel.pane import PaneBase
7 2
from panel.util import get_method_owner, abbreviated_repr
8

9

10 2
def test_get_method_owner_class():
11 2
    assert get_method_owner(PaneBase.get_pane_type) is PaneBase
12

13

14 2
def test_get_method_owner_instance():
15 2
    div = Div()
16 2
    assert get_method_owner(div.update) is div
17

18

19 2
def test_render_mimebundle(document, comm):
20 2
    div = Div()
21 2
    data, metadata = render_mimebundle(div, document, comm)
22

23 2
    assert metadata == {'application/vnd.holoviews_exec.v0+json': {'id': div.ref['id']}}
24 2
    assert 'application/vnd.holoviews_exec.v0+json' in data
25 2
    assert 'text/html' in data
26 2
    assert data['application/vnd.holoviews_exec.v0+json'] == ''
27

28

29 2
def test_abbreviated_repr_dict():
30 2
    assert abbreviated_repr({'key': 'some really, really long string'}) == "{'key': 'some really, ...}"
31

32

33 2
def test_abbreviated_repr_list():
34 2
    assert abbreviated_repr(['some really, really long string']) == "['some really, ...]"
35

36

37 2
def test_abbreviated_repr_ordereddict():
38 2
    assert (abbreviated_repr(OrderedDict([('key', 'some really, really long string')]))
39
            == "OrderedDict([('key', ...])")

Read our documentation on viewing source code .

Loading