1 6
from __future__ import absolute_import
2

3 6
import pytest
4

5 6
import param
6

7 6
from panel.interact import interactive
8 6
from panel.pane import Pane, PaneBase, Bokeh, HoloViews, IPyWidget, Interactive
9 6
from panel.param import ParamMethod
10 6
from panel.tests.util import check_layoutable_properties, py3_only
11

12

13 6
all_panes = [w for w in param.concrete_descendents(PaneBase).values()
14
             if not w.__name__.startswith('_') and not
15
             issubclass(w, (Bokeh, HoloViews, ParamMethod, interactive, IPyWidget, Interactive))
16
             and w.__module__.startswith('panel')]
17

18

19 6
def test_pane_repr(document, comm):
20 6
    pane = Pane('Some text', width=400)
21 6
    assert repr(pane) == 'Markdown(str, width=400)'
22

23

24 6
@pytest.mark.parametrize('pane', all_panes)
25 1
def test_pane_layout_properties(pane, document, comm):
26 6
    try:
27 6
        p = pane()
28 0
    except ImportError:
29 0
        pytest.skip("Dependent library could not be imported.")
30 6
    model = p.get_root(document, comm)
31 6
    check_layoutable_properties(p, model)
32

33

34 6
@pytest.mark.parametrize('pane', all_panes)
35 1
def test_pane_clone(pane):
36 6
    try:
37 6
        p = pane()
38 0
    except ImportError:
39 0
        pytest.skip("Dependent library could not be imported.")
40 6
    clone = p.clone()
41

42 6
    assert ([(k, v) for k, v in sorted(p.param.get_param_values()) if k != 'name'] ==
43
            [(k, v) for k, v in sorted(clone.param.get_param_values()) if k != 'name'])
44

45

46 6
@py3_only
47 6
@pytest.mark.parametrize('pane', all_panes)
48 1
def test_pane_signature(pane):
49 6
    from inspect import Parameter, signature
50 6
    parameters = signature(pane).parameters
51 6
    assert len(parameters) == 2
52 6
    assert 'object' in parameters
53 6
    assert parameters['object'] == Parameter('object', Parameter.POSITIONAL_OR_KEYWORD, default=None)

Read our documentation on viewing source code .

Loading