/
test_docs.py
53 lines (38 loc) · 1.79 KB
/
test_docs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
These tests verify that all of the panes, layouts, and widgets defined by panel are
represented in the reference gallery.
"""
import os
from inspect import isclass
import pytest
import panel as pn
here = os.path.abspath(os.path.dirname(__file__))
ref = os.path.join(here, '..', '..', 'examples', 'reference')
docs_available = pytest.mark.skipif(not os.path.isdir(ref), reason="docs not found")
@docs_available
def test_layouts_are_in_reference_gallery():
exceptions = set(['ListPanel', 'Panel'])
docs = {os.path.splitext(f)[0] for f in os.listdir(os.path.join(ref, 'layouts'))}
def is_panel_layout(attr):
layout = getattr(pn.layout, attr)
return isclass(layout) and issubclass(layout, pn.layout.Panel)
layouts = set(filter(is_panel_layout, dir(pn.layout)))
assert layouts - exceptions - docs == set()
@docs_available
def test_widgets_are_in_reference_gallery():
exceptions = set(['CompositeWidget', 'Widget', 'ToggleGroup', 'NumberInput', 'Spinner'])
docs = {os.path.splitext(f)[0] for g in ('indicators', 'widgets') for f in os.listdir(os.path.join(ref, g))}
def is_panel_widget(attr):
widget = getattr(pn.widgets, attr)
return isclass(widget) and issubclass(widget, pn.widgets.Widget)
widgets = set(filter(is_panel_widget, dir(pn.widgets)))
assert widgets - exceptions - docs == set()
@docs_available
def test_panes_are_in_reference_gallery():
exceptions = set(['PaneBase', 'YT', 'RGGPlot', 'Interactive', 'ICO'])
docs = {os.path.splitext(f)[0] for f in os.listdir(os.path.join(ref, 'panes'))}
def is_panel_pane(attr):
pane = getattr(pn.pane, attr)
return isclass(pane) and issubclass(pane, pn.pane.PaneBase)
panes = set(filter(is_panel_pane, dir(pn.pane)))
assert panes - exceptions - docs == set()