Skip to content

Commit 8b8c3eb

Browse files
authored
Run unit tests with param warnings as exceptions by default (#1528)
1 parent 13c8293 commit 8b8c3eb

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

hvplot/tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import dask
2+
import param
3+
import pytest
4+
5+
from packaging.version import Version
6+
7+
param.parameterized.warnings_as_exceptions = True
28

39
from packaging.version import Version
410

@@ -43,3 +49,13 @@ def pytest_collection_modifyitems(config, items):
4349
# From Dask 2024.3.0 they now use `dask_expr` by default
4450
# https://github.com/dask/dask/issues/10995
4551
dask.config.set({'dataframe.query-planning': False})
52+
53+
54+
@pytest.fixture
55+
def disable_param_warnings_as_exceptions():
56+
original = param.parameterized.warnings_as_exceptions
57+
param.parameterized.warnings_as_exceptions = False
58+
try:
59+
yield
60+
finally:
61+
param.parameterized.warnings_as_exceptions = original

hvplot/tests/testhelp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def test_help_style_extension_output(reset_default_backend):
6060
)
6161

6262

63+
@pytest.mark.usefixtures('disable_param_warnings_as_exceptions')
6364
def test_help_style_compatibility(reset_default_backend):
6465
# The current backend is plotly but the style options are those of matplotlib
6566
hvplot.extension('plotly', 'matplotlib', compatibility='matplotlib')

hvplot/tests/testoverrides.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import numpy as np
44
import pandas as pd
5+
import pytest
56
import xarray as xr
67

78
from hvplot.plotting import hvPlot, hvPlotTabular
@@ -44,6 +45,7 @@ def test_define_customize_method(self):
4445
self.assertNotEqual(opts.options.get('width'), 42)
4546
self.assertNotEqual(opts.options.get('height'), 42)
4647

48+
@pytest.mark.usefixtures('disable_param_warnings_as_exceptions')
4749
def test_attempt_to_override_kind_on_method(self):
4850
hvplot = hvPlotTabular(self.df, {'scatter': {'kind': 'line'}})
4951
self.assertIsInstance(hvplot.scatter(y='y'), Scatter)

hvplot/tests/testui.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def test_explorer_kwargs_controls():
123123
assert explorer.axes.width == 200
124124

125125

126+
@pytest.mark.usefixtures('disable_param_warnings_as_exceptions')
126127
def test_explorer_kwargs_controls_error_not_supported():
127128
with pytest.raises(
128129
TypeError,
@@ -391,6 +392,7 @@ def test_explorer_xarray_multi_var_extra_dims_no_coord():
391392
assert ds.hvplot.explorer()
392393

393394

395+
@pytest.mark.usefixtures('disable_param_warnings_as_exceptions')
394396
@pytest.mark.parametrize('kind_tuple', [('scatter', 'points'), ('line', 'paths')])
395397
@pytest.mark.geo
396398
def test_explorer_geo_revise_kind(kind_tuple):
@@ -399,6 +401,7 @@ def test_explorer_geo_revise_kind(kind_tuple):
399401
assert explorer.kind == kind_tuple[1]
400402

401403

404+
@pytest.mark.usefixtures('disable_param_warnings_as_exceptions')
402405
def test_max_rows_curve():
403406
N = 100001
404407
x = np.linspace(0.0, 6.4, num=N)
@@ -408,6 +411,7 @@ def test_max_rows_curve():
408411
assert ui._data.equals(df.head(MAX_ROWS))
409412

410413

414+
@pytest.mark.usefixtures('disable_param_warnings_as_exceptions')
411415
def test_max_rows_sample():
412416
N = 100001
413417
x = np.linspace(0.0, 6.4, num=N)

hvplot/ui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,11 @@ def __init__(self, df, **params):
553553
if 'y' in params:
554554
params['y_multi'] = params.pop('y') if isinstance(params['y'], list) else [params['y']]
555555
statusbar_params = {k: params.pop(k) for k in params.copy() if k in StatusBar.param}
556+
opts_kwargs = params.pop('opts', {})
556557
converter = _hvConverter(
557558
df, x, y, **{k: v for k, v in params.items() if k not in ('x', 'y', 'y_multi')}
558559
)
560+
params['opts'] = opts_kwargs
559561
# Collect kwargs passed to the constructor but meant for the controls
560562
extras = {k: params.pop(k) for k in params.copy() if k not in self.param}
561563
super().__init__(**params)

0 commit comments

Comments
 (0)