|
| 1 | +import hvplot.pandas |
| 2 | +import pytest |
| 3 | + |
| 4 | +from holoviews.core import Store |
| 5 | +from holoviews.element import Curve |
| 6 | + |
| 7 | + |
| 8 | +@pytest.fixture |
| 9 | +def reset_default_backend(): |
| 10 | + yield |
| 11 | + hvplot.extension('bokeh') |
| 12 | + hvplot.extension.compatibility = None |
| 13 | + |
| 14 | + |
| 15 | +def test_help_style_extension_output(reset_default_backend): |
| 16 | + # default, after e.g. import hvplot.pandas |
| 17 | + docstring, signature = hvplot._get_doc_and_signature( |
| 18 | + cls=hvplot.hvPlot, |
| 19 | + kind='line', |
| 20 | + completions=False, |
| 21 | + docstring=False, |
| 22 | + generic=False, |
| 23 | + style=True, |
| 24 | + signature=None, |
| 25 | + ) |
| 26 | + assert docstring == '\nStyle options\n-------------\n\n' + '\n'.join(sorted(Store.registry['bokeh'][Curve].style_opts)) |
| 27 | + |
| 28 | + # The current backend becomes matplotlib |
| 29 | + hvplot.extension('matplotlib', 'plotly') |
| 30 | + docstring, signature = hvplot._get_doc_and_signature( |
| 31 | + cls=hvplot.hvPlot, |
| 32 | + kind='line', |
| 33 | + completions=False, |
| 34 | + docstring=False, |
| 35 | + generic=False, |
| 36 | + style=True, |
| 37 | + signature=None, |
| 38 | + ) |
| 39 | + assert docstring == '\nStyle options\n-------------\n\n' + '\n'.join(sorted(Store.registry['matplotlib'][Curve].style_opts)) |
| 40 | + |
| 41 | + # The current backend becomes plotly |
| 42 | + hvplot.output(backend='plotly') |
| 43 | + docstring, signature = hvplot._get_doc_and_signature( |
| 44 | + cls=hvplot.hvPlot, |
| 45 | + kind='line', |
| 46 | + completions=False, |
| 47 | + docstring=False, |
| 48 | + generic=False, |
| 49 | + style=True, |
| 50 | + signature=None, |
| 51 | + ) |
| 52 | + assert docstring == '\nStyle options\n-------------\n\n' + '\n'.join(sorted(Store.registry['plotly'][Curve].style_opts)) |
| 53 | + |
| 54 | +def test_help_style_compatibility(reset_default_backend): |
| 55 | + # The current backend is plotly but the style options are those of matplotlib |
| 56 | + hvplot.extension('plotly', 'matplotlib', compatibility='matplotlib') |
| 57 | + docstring, signature = hvplot._get_doc_and_signature( |
| 58 | + cls=hvplot.hvPlot, |
| 59 | + kind='line', |
| 60 | + completions=False, |
| 61 | + docstring=False, |
| 62 | + generic=False, |
| 63 | + style=True, |
| 64 | + signature=None, |
| 65 | + ) |
| 66 | + assert docstring == '\nStyle options\n-------------\n\n' + '\n'.join(sorted(Store.registry['matplotlib'][Curve].style_opts)) |
0 commit comments