Skip to content

fix: cleaning up tests for release #4977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ commands:
name: Test core
command: |
. venv/bin/activate
pytest plotly/tests/test_core
python -m pytest plotly/tests/test_core
no_output_timeout: 20m

test_optional:
Expand Down Expand Up @@ -55,36 +55,36 @@ commands:
name: Test core
command: |
. venv/bin/activate
pytest plotly/tests/test_core
python -m pytest plotly/tests/test_core
no_output_timeout: 20m
- run:
name: Test optional
command: |
. venv/bin/activate
pytest plotly/tests/test_optional
python -m pytest plotly/tests/test_optional
no_output_timeout: 40m
- run:
name: Test utils
command: |
. venv/bin/activate
pytest _plotly_utils/tests/
python -m pytest _plotly_utils/tests/
no_output_timeout: 20m
- run:
name: Test io
command: |
. venv/bin/activate
pytest plotly/tests/test_io
python -m pytest plotly/tests/test_io
no_output_timeout: 20m
- run:
name: Test dependencdies not imported
command: |
. venv/bin/activate
pytest -x test_init/test_dependencies_not_imported.py
python -m pytest -x test_init/test_dependencies_not_imported.py
- run:
name: Test lazy imports
command: |
. venv/bin/activate
pytest -x test_init/test_lazy_imports.py
python -m pytest -x test_init/test_lazy_imports.py
test_orca:
parameters:
py:
Expand Down Expand Up @@ -118,7 +118,7 @@ commands:
name: Test orca
command: |
. venv/bin/activate
pytest plotly/tests/test_orca
python -m pytest plotly/tests/test_orca
no_output_timeout: 20m
- store_artifacts:
path: plotly/tests/test_orca/images/linux/failed
Expand Down Expand Up @@ -329,7 +329,7 @@ jobs:
command: |
. venv/bin/activate
locale
pytest -k 'not nodev' plotly/tests/test_core
python -m pytest -k 'not nodev' plotly/tests/test_core
no_output_timeout: 20m
- run:
name: Commit
Expand Down
4 changes: 2 additions & 2 deletions _plotly_utils/tests/validators/test_enumerated_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def validator():

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


Expand All @@ -26,7 +26,7 @@ def validator_aok():

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


Expand Down
20 changes: 10 additions & 10 deletions plotly/tests/test_core/test_subplots/test_make_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,10 +1954,10 @@ def test_make_subplots_spacing_error():
# vertical_spacing is raised when spacing exceeds that value
for match in [
(
"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
r"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
% ("Vertical", "rows", 1.0 / 50.0)
).replace(".", "\."),
"The resulting plot would have 51 rows \(rows=51\)\.$",
).replace(".", r"\."),
r"The resulting plot would have 51 rows \(rows=51\)\.$",
]:
with pytest.raises(
ValueError,
Expand All @@ -1966,10 +1966,10 @@ def test_make_subplots_spacing_error():
fig = subplots.make_subplots(51, 1, vertical_spacing=0.0201)
for match in [
(
"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
r"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
% ("Horizontal", "cols", 1.0 / 50.0)
).replace(".", "\."),
"The resulting plot would have 51 columns \(cols=51\)\.$",
).replace(".", r"\."),
r"The resulting plot would have 51 columns \(cols=51\)\.$",
]:
with pytest.raises(
ValueError,
Expand Down Expand Up @@ -2011,18 +2011,18 @@ def test_make_subplots_spacing_error():
# This shouldn't happen so we assert False to force failure
assert False
with pytest.raises(
ValueError, match="^Horizontal spacing must be between 0 and 1\.$"
ValueError, match=r"^Horizontal spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, horizontal_spacing=-0.01)
with pytest.raises(
ValueError, match="^Horizontal spacing must be between 0 and 1\.$"
ValueError, match=r"^Horizontal spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, horizontal_spacing=1.01)
with pytest.raises(
ValueError, match="^Vertical spacing must be between 0 and 1\.$"
ValueError, match=r"^Vertical spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, vertical_spacing=-0.01)
with pytest.raises(
ValueError, match="^Vertical spacing must be between 0 and 1\.$"
ValueError, match=r"^Vertical spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, vertical_spacing=1.01)
3 changes: 2 additions & 1 deletion plotly/tests/test_io/test_to_from_plotly_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def test_sanitize_json(engine):
fig = go.Figure(layout=layout)
fig_json = pio.to_json_plotly(fig, engine=engine)
layout_2 = json.loads(fig_json)["layout"]
del layout_2["template"]
if "template" in layout_2:
del layout_2["template"]

assert layout == layout_2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_np_layers(self):
"center": {"lon": 0.5, "lat": 51},
},
}
data = [{"type": "scattermapbox"}]
data = [{"type": "scattermap"}]

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

Expand Down
2 changes: 1 addition & 1 deletion plotly/tests/test_optional/test_px/test_px_hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_sunburst_hoverdict_color(backend):

def test_date_in_hover(constructor):
df = nw.from_native(
constructor({"date": ["2015-04-04 19:31:30+01:00"], "value": [3]})
constructor({"date": ["2015-04-04 19:31:30+0100"], "value": [3]})
).with_columns(date=nw.col("date").str.to_datetime(format="%Y-%m-%d %H:%M:%S%z"))
fig = px.scatter(df.to_native(), x="value", y="value", hover_data=["date"])

Expand Down
14 changes: 11 additions & 3 deletions plotly/tests/test_optional/test_px/test_px_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
from packaging import version
import unittest.mock as mock
from plotly.express._core import build_dataframe
from plotly import optional_imports
from pandas.testing import assert_frame_equal
import sys
import warnings


# FIXME: don't test with vaex if vaex isn't installed
if (optional_imports.get_module("vaex") is None) and (sys.version_info >= (3, 12)):
TEST_LIBS = ["polars"]
else:
TEST_LIBS = ["vaex", "polars"]


def test_numpy():
fig = px.scatter(x=[1, 2, 3], y=[2, 3, 4], color=[1, 3, 9])
assert np.all(fig.data[0].x == np.array([1, 2, 3]))
Expand Down Expand Up @@ -342,7 +350,7 @@ def __dataframe__(self, allow_copy: bool = True):
or sys.version_info >= (3, 12),
reason="plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2",
)
@pytest.mark.parametrize("test_lib", ["vaex", "polars"])
@pytest.mark.parametrize("test_lib", TEST_LIBS)
def test_build_df_from_vaex_and_polars(test_lib):
if test_lib == "vaex":
import vaex as lib
Expand All @@ -365,7 +373,7 @@ def test_build_df_from_vaex_and_polars(test_lib):
or sys.version_info >= (3, 12),
reason="plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2",
)
@pytest.mark.parametrize("test_lib", ["vaex", "polars"])
@pytest.mark.parametrize("test_lib", TEST_LIBS)
@pytest.mark.parametrize(
"hover_data", [["sepal_width"], {"sepal_length": False, "sepal_width": ":.2f"}]
)
Expand Down Expand Up @@ -393,7 +401,7 @@ def test_build_df_with_hover_data_from_vaex_and_polars(test_lib, hover_data):

def test_timezones(constructor):
df = nw.from_native(
constructor({"date": ["2015-04-04 19:31:30+01:00"], "value": [3]})
constructor({"date": ["2015-04-04 19:31:30+0100"], "value": [3]})
).with_columns(nw.col("date").str.to_datetime(format="%Y-%m-%d %H:%M:%S%z"))
args = dict(data_frame=df.to_native(), x="date", y="value")
out = build_dataframe(args, go.Scatter)
Expand Down
Empty file removed plotly/tests/test_orca/__init__.py
Empty file.
Loading