1
"""
2
These tests verify that all of the panes, layouts, and widgets defined by panel are
3
represented in the reference gallery.
4
"""
5 2
from __future__ import absolute_import, division, unicode_literals
6

7 2
import os
8

9 2
from inspect import isclass
10

11 2
import pytest
12 2
import panel as pn
13

14 2
here = os.path.abspath(os.path.dirname(__file__))
15 2
ref = os.path.join(here, '..', '..', 'examples', 'reference')
16 2
docs_available = pytest.mark.skipif(not os.path.isdir(ref), reason="docs not found")
17

18

19 2
@docs_available
20
def test_layouts_are_in_reference_gallery():
21 2
    exceptions = set(['ListPanel', 'Panel'])
22 2
    docs = {os.path.splitext(f)[0] for f in os.listdir(os.path.join(ref, 'layouts'))}
23

24 2
    def is_panel_layout(attr):
25 2
        layout = getattr(pn.layout, attr)
26 2
        return isclass(layout) and issubclass(layout, pn.layout.Panel)
27

28 2
    layouts = set(filter(is_panel_layout, dir(pn.layout)))
29 2
    assert layouts - exceptions - docs == set()
30

31

32 2
@docs_available
33
def test_widgets_are_in_reference_gallery():
34 2
    exceptions = set(['CompositeWidget', 'Widget', 'ToggleGroup'])
35 2
    docs = {os.path.splitext(f)[0] for g in ('indicators', 'widgets') for f in os.listdir(os.path.join(ref, g))}
36

37 2
    def is_panel_widget(attr):
38 2
        widget = getattr(pn.widgets, attr)
39 2
        return isclass(widget) and issubclass(widget, pn.widgets.Widget)
40

41 2
    widgets = set(filter(is_panel_widget, dir(pn.widgets)))
42 2
    assert widgets - exceptions - docs == set()
43

44

45 2
@docs_available
46
def test_panes_are_in_reference_gallery():
47 2
    exceptions = set(['PaneBase', 'YT', 'RGGPlot'])
48 2
    docs = {os.path.splitext(f)[0] for f in os.listdir(os.path.join(ref, 'panes'))}
49

50 2
    def is_panel_pane(attr):
51 2
        pane = getattr(pn.pane, attr)
52 2
        return isclass(pane) and issubclass(pane, pn.pane.PaneBase)
53

54 2
    panes = set(filter(is_panel_pane, dir(pn.pane)))
55 2
    assert panes - exceptions - docs == set()

Read our documentation on viewing source code .

Loading