Skip to content

Commit 4ce53bc

Browse files
committed
testing
1 parent 86a7e12 commit 4ce53bc

File tree

9 files changed

+41
-25
lines changed

9 files changed

+41
-25
lines changed

_plotly_utils/tests/validators/test_enumerated_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def validator():
1414

1515
@pytest.fixture()
1616
def validator_re():
17-
values = ["foo", "/bar(\d)+/", "baz"]
17+
values = ["foo", r"/bar(\d)+/", "baz"]
1818
return EnumeratedValidator("prop", "parent", values, array_ok=False)
1919

2020

@@ -26,7 +26,7 @@ def validator_aok():
2626

2727
@pytest.fixture()
2828
def validator_aok_re():
29-
values = ["foo", "/bar(\d)+/", "baz"]
29+
values = ["foo", r"/bar(\d)+/", "baz"]
3030
return EnumeratedValidator("prop", "parent", values, array_ok=True)
3131

3232

plotly/tests/test_core/test_subplots/test_make_subplots.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,10 +1954,10 @@ def test_make_subplots_spacing_error():
19541954
# vertical_spacing is raised when spacing exceeds that value
19551955
for match in [
19561956
(
1957-
"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
1957+
r"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
19581958
% ("Vertical", "rows", 1.0 / 50.0)
1959-
).replace(".", "\."),
1960-
"The resulting plot would have 51 rows \(rows=51\)\.$",
1959+
).replace(".", r"\."),
1960+
r"The resulting plot would have 51 rows \(rows=51\)\.$",
19611961
]:
19621962
with pytest.raises(
19631963
ValueError,
@@ -1966,10 +1966,10 @@ def test_make_subplots_spacing_error():
19661966
fig = subplots.make_subplots(51, 1, vertical_spacing=0.0201)
19671967
for match in [
19681968
(
1969-
"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
1969+
r"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
19701970
% ("Horizontal", "cols", 1.0 / 50.0)
1971-
).replace(".", "\."),
1972-
"The resulting plot would have 51 columns \(cols=51\)\.$",
1971+
).replace(".", r"\."),
1972+
r"The resulting plot would have 51 columns \(cols=51\)\.$",
19731973
]:
19741974
with pytest.raises(
19751975
ValueError,
@@ -2011,18 +2011,18 @@ def test_make_subplots_spacing_error():
20112011
# This shouldn't happen so we assert False to force failure
20122012
assert False
20132013
with pytest.raises(
2014-
ValueError, match="^Horizontal spacing must be between 0 and 1\.$"
2014+
ValueError, match=r"^Horizontal spacing must be between 0 and 1\.$"
20152015
):
20162016
fig = subplots.make_subplots(1, 1, horizontal_spacing=-0.01)
20172017
with pytest.raises(
2018-
ValueError, match="^Horizontal spacing must be between 0 and 1\.$"
2018+
ValueError, match=r"^Horizontal spacing must be between 0 and 1\.$"
20192019
):
20202020
fig = subplots.make_subplots(1, 1, horizontal_spacing=1.01)
20212021
with pytest.raises(
2022-
ValueError, match="^Vertical spacing must be between 0 and 1\.$"
2022+
ValueError, match=r"^Vertical spacing must be between 0 and 1\.$"
20232023
):
20242024
fig = subplots.make_subplots(1, 1, vertical_spacing=-0.01)
20252025
with pytest.raises(
2026-
ValueError, match="^Vertical spacing must be between 0 and 1\.$"
2026+
ValueError, match=r"^Vertical spacing must be between 0 and 1\.$"
20272027
):
20282028
fig = subplots.make_subplots(1, 1, vertical_spacing=1.01)

plotly/tests/test_io/test_to_from_plotly_json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ def test_sanitize_json(engine):
244244
fig = go.Figure(layout=layout)
245245
fig_json = pio.to_json_plotly(fig, engine=engine)
246246
layout_2 = json.loads(fig_json)["layout"]
247-
del layout_2["template"]
248247

249248
assert layout == layout_2
250249

plotly/tests/test_optional/test_graph_objs/test_skipped_b64_keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_np_layers(self):
6666
"center": {"lon": 0.5, "lat": 51},
6767
},
6868
}
69-
data = [{"type": "scattermapbox"}]
69+
data = [{"type": "scattermap"}]
7070

7171
fig = go.Figure(data=data, layout=layout)
7272

plotly/tests/test_optional/test_px/test_px_hover.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ def test_sunburst_hoverdict_color(backend):
184184
assert "color" in fig.data[0].hovertemplate
185185

186186

187-
def test_date_in_hover(constructor):
187+
def test_date_in_hover(request, constructor):
188+
# FIXME: PyArrow requires a different format for datetime constructors with timezones
189+
from .conftest import pyarrow_table_constructor
190+
if constructor is pyarrow_table_constructor:
191+
request.applymarker(pytest.mark.xfail)
192+
188193
df = nw.from_native(
189194
constructor({"date": ["2015-04-04 19:31:30+01:00"], "value": [3]})
190195
).with_columns(date=nw.col("date").str.to_datetime(format="%Y-%m-%d %H:%M:%S%z"))

plotly/tests/test_optional/test_px/test_px_input.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@
88
from packaging import version
99
import unittest.mock as mock
1010
from plotly.express._core import build_dataframe
11+
from plotly import optional_imports
1112
from pandas.testing import assert_frame_equal
1213
import sys
1314
import warnings
1415

1516

17+
# FIXME: don't test with vaex if vaex isn't installed
18+
if (optional_imports.get_module("vaex") is None) and (sys.version_info >= (3, 12)):
19+
TEST_LIBS = ["polars"]
20+
else:
21+
TEST_LIBS = ["vaex", "polars"]
22+
23+
1624
def test_numpy():
1725
fig = px.scatter(x=[1, 2, 3], y=[2, 3, 4], color=[1, 3, 9])
1826
assert np.all(fig.data[0].x == np.array([1, 2, 3]))
@@ -342,7 +350,7 @@ def __dataframe__(self, allow_copy: bool = True):
342350
or sys.version_info >= (3, 12),
343351
reason="plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2",
344352
)
345-
@pytest.mark.parametrize("test_lib", ["vaex", "polars"])
353+
@pytest.mark.parametrize("test_lib", TEST_LIBS)
346354
def test_build_df_from_vaex_and_polars(test_lib):
347355
if test_lib == "vaex":
348356
import vaex as lib
@@ -365,7 +373,7 @@ def test_build_df_from_vaex_and_polars(test_lib):
365373
or sys.version_info >= (3, 12),
366374
reason="plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2",
367375
)
368-
@pytest.mark.parametrize("test_lib", ["vaex", "polars"])
376+
@pytest.mark.parametrize("test_lib", TEST_LIBS)
369377
@pytest.mark.parametrize(
370378
"hover_data", [["sepal_width"], {"sepal_length": False, "sepal_width": ":.2f"}]
371379
)
@@ -391,7 +399,12 @@ def test_build_df_with_hover_data_from_vaex_and_polars(test_lib, hover_data):
391399
)
392400

393401

394-
def test_timezones(constructor):
402+
def test_timezones(request, constructor):
403+
# FIXME: PyArrow requires a different format for datetime constructors with timezones
404+
from .conftest import pyarrow_table_constructor
405+
if constructor is pyarrow_table_constructor:
406+
request.applymarker(pytest.mark.xfail)
407+
395408
df = nw.from_native(
396409
constructor({"date": ["2015-04-04 19:31:30+01:00"], "value": [3]})
397410
).with_columns(nw.col("date").str.to_datetime(format="%Y-%m-%d %H:%M:%S%z"))

requires-optional.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@ numpy
2020
# matplotlib==2.2.2
2121

2222
## testing dependencies ##
23+
# see also test_requirements/*.txt for specific Python versions
2324
coverage==4.3.1
2425
mock==2.0.0
2526
pytest==8.1.1
2627
xarray
2728
pytz
2829

29-
## orca dependencies ##
30-
requests
31-
psutil
32-
3330
## code formatting ##
3431
pre-commit
3532
black==22.3.0

test_requirements/requirements_311_optional.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ pyshp==2.1.3
1616
matplotlib==3.8.0
1717
scikit-image==0.22.0
1818
psutil==5.7.0
19-
kaleido
2019
orjson==3.8.12
21-
polars[timezone]
22-
pyarrow
2320
narwhals>=1.15.1
2421
anywidget==0.9.13
22+
polars[timezone]
23+
pyarrow
24+
kaleido
25+
plotly-geo

test_requirements/requirements_312_optional.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ pyarrow
2323
narwhals>=1.15.1
2424
anywidget==0.9.13
2525
jupyter-console==6.4.4
26+
plotly-geo

0 commit comments

Comments
 (0)