Skip to content

Commit 6c01e81

Browse files
committed
refactor: get tests/**/*.py to pass ruff check .
1 parent 5b9b731 commit 6c01e81

File tree

65 files changed

+297
-440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+297
-440
lines changed

tests/percy/plotly-express.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
# this directory
1010
dir_name = os.path.join("tests", "percy")
1111

12-
# #### Scatter and Line plots
13-
12+
# Scatter and Line plots
1413

1514
iris = px.data.iris()
1615
fig = px.scatter(iris, x="sepal_width", y="sepal_length")
@@ -196,8 +195,7 @@
196195
fig = px.area(gapminder, x="year", y="pop", color="continent", line_group="country")
197196
fig.write_html(os.path.join(dir_name, "area.html"))
198197

199-
# #### Visualize Distributions
200-
198+
# Visualize Distributions
201199

202200
iris = px.data.iris()
203201
fig = px.density_contour(iris, x="sepal_width", y="sepal_length")
@@ -286,8 +284,7 @@
286284
)
287285
fig.write_html(os.path.join(dir_name, "violin.html"))
288286

289-
# #### Ternary Coordinates
290-
287+
# Ternary Coordinates
291288

292289
election = px.data.election()
293290
fig = px.scatter_ternary(
@@ -318,8 +315,7 @@
318315
fig = px.imshow(img_rgb)
319316
fig.write_html(os.path.join(dir_name, "imshow.html"))
320317

321-
# #### 3D Coordinates
322-
318+
# 3D Coordinates
323319

324320
election = px.data.election()
325321
fig = px.scatter_3d(
@@ -342,8 +338,7 @@
342338
)
343339
fig.write_html(os.path.join(dir_name, "line_3d.html"))
344340

345-
# #### Polar Coordinates
346-
341+
# Polar Coordinates
347342

348343
wind = px.data.wind()
349344
fig = px.scatter_polar(
@@ -380,8 +375,7 @@
380375
)
381376
fig.write_html(os.path.join(dir_name, "bar_polar.html"))
382377

383-
# #### Maps
384-
378+
# Maps
385379

386380
carshare = px.data.carshare()
387381
fig = px.scatter_map(

tests/test_core/test_colors/test_colors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from unittest import TestCase
22

3-
import plotly.tools as tls
43
from plotly.exceptions import PlotlyError
54
import plotly.colors as colors
65

tests/test_core/test_errors/test_dict_path_errors.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import plotly.graph_objects as go
2-
from _plotly_utils.exceptions import PlotlyKeyError
32
import pytest
43
import sys
54

@@ -23,7 +22,7 @@ def test_raises_on_bad_index(some_fig):
2322
# Check indexing errors can be detected when path used as key to go.Figure
2423
raised = False
2524
try:
26-
x0 = some_fig["layout.shapes[2].x0"]
25+
some_fig["layout.shapes[2].x0"]
2726
except KeyError as e:
2827
raised = True
2928
assert (
@@ -43,7 +42,7 @@ def test_raises_on_bad_dot_property(some_fig):
4342
# go.Figure
4443
raised = False
4544
try:
46-
x2000 = some_fig["layout.shapes[1].x2000"]
45+
some_fig["layout.shapes[1].x2000"]
4746
except KeyError as e:
4847
raised = True
4948
assert (
@@ -62,7 +61,7 @@ def test_raises_on_bad_ancestor_dot_property(some_fig):
6261
# Check . property lookup errors but not on the last part of the path
6362
raised = False
6463
try:
65-
x2000 = some_fig["layout.shapa[1].x2000"]
64+
some_fig["layout.shapa[1].x2000"]
6665
except KeyError as e:
6766
raised = True
6867
assert (
@@ -181,7 +180,7 @@ def test_raises_on_bad_indexed_underscore_property(some_fig):
181180
# BaseFigure and throws the error for the last good property found in
182181
# the path
183182
try:
184-
fig2 = go.Figure(layout=dict(title=dict(txt="two")))
183+
go.Figure(layout=dict(title=dict(txt="two")))
185184
except ValueError as e_correct:
186185
raised = True
187186
e_correct_substr = error_substr(
@@ -195,7 +194,7 @@ def test_raises_on_bad_indexed_underscore_property(some_fig):
195194

196195
raised = False
197196
try:
198-
fig2 = go.Figure(layout_title_txt="two")
197+
go.Figure(layout_title_txt="two")
199198
except TypeError as e:
200199
raised = True
201200
# when the Figure constructor sees the same ValueError above, a
@@ -421,14 +420,14 @@ def test_subscript_error_exception_types(some_fig):
421420
with pytest.raises(ValueError):
422421
some_fig.update_layout(width_yo=100)
423422
with pytest.raises(KeyError):
424-
yo = some_fig["layout_width_yo"]
423+
some_fig["layout_width_yo"]
425424

426425
some_fig.update_layout(width=100)
427426
# when width is specified
428427
with pytest.raises(ValueError):
429428
some_fig.update_layout(width_yo=100)
430429
with pytest.raises(KeyError):
431-
yo = some_fig["layout_width_yo"]
430+
some_fig["layout_width_yo"]
432431

433432

434433
def form_error_string(call, exception, subs):

tests/test_core/test_figure_messages/test_add_traces.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import sys
21
from unittest import TestCase
32

43
import plotly.graph_objs as go
54
from plotly.subplots import make_subplots
65

7-
if sys.version_info >= (3, 3):
8-
from unittest.mock import MagicMock
9-
else:
10-
from mock import MagicMock
6+
from unittest.mock import MagicMock
117

128

139
class TestAddTracesMessage(TestCase):
@@ -56,8 +52,6 @@ def test_add_traces(self):
5652
self.assertEqual(self.figure.data[-1].line.color, "cyan")
5753

5854
# Check message
59-
new_uid1 = self.figure.data[-2].uid
60-
new_uid2 = self.figure.data[-1].uid
6155
self.figure._send_addTraces_msg.assert_called_once_with(
6256
[
6357
{"type": "sankey", "arrangement": "snap"},

tests/test_core/test_figure_messages/test_batch_animate.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import sys
21
from unittest import TestCase
32

43
import plotly.graph_objs as go
54

6-
if sys.version_info >= (3, 3):
7-
from unittest.mock import MagicMock
8-
else:
9-
from mock import MagicMock
5+
from unittest.mock import MagicMock
106

117

128
class TestBatchAnimateMessage(TestCase):

tests/test_core/test_figure_messages/test_move_delete_traces.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import sys
21
from unittest import TestCase
32
import pytest
43

54
import plotly.graph_objs as go
65

7-
if sys.version_info >= (3, 3):
8-
from unittest.mock import MagicMock
9-
else:
10-
from mock import MagicMock
6+
from unittest.mock import MagicMock
117

128

139
class TestMoveDeleteTracesMessages(TestCase):

tests/test_core/test_figure_messages/test_on_change.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import sys
21
from unittest import TestCase
32
import pytest
43

54
import plotly.graph_objs as go
65

7-
if sys.version_info >= (3, 3):
8-
from unittest.mock import MagicMock
9-
else:
10-
from mock import MagicMock
6+
from unittest.mock import MagicMock
117

128

139
class TestOnChangeCallbacks(TestCase):
@@ -35,12 +31,12 @@ def test_raise_on_frame_hierarchy(self):
3531
with pytest.raises(ValueError):
3632
self.figure.frames[0].layout.xaxis.on_change(fn, "range")
3733

38-
def test_validate_property_path_nested(self):
34+
def test_validate_property_path_nested_1(self):
3935
fn = MagicMock()
4036
with pytest.raises(ValueError):
4137
self.figure.layout.xaxis.on_change(fn, "bogus")
4238

43-
def test_validate_property_path_nested(self):
39+
def test_validate_property_path_nested_2(self):
4440
fn = MagicMock()
4541
with pytest.raises(ValueError):
4642
self.figure.layout.on_change(fn, "xaxis.title_font.bogus")

tests/test_core/test_figure_messages/test_plotly_relayout.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import sys
21
from unittest import TestCase
32

43
import plotly.graph_objs as go
54

6-
if sys.version_info >= (3, 3):
7-
from unittest.mock import MagicMock
8-
else:
9-
from mock import MagicMock
5+
from unittest.mock import MagicMock
106

117

128
class TestRelayoutMessage(TestCase):

tests/test_core/test_figure_messages/test_plotly_restyle.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import sys
21
from unittest import TestCase
32

43
import plotly.graph_objs as go
54

6-
if sys.version_info >= (3, 3):
7-
from unittest.mock import MagicMock
8-
else:
9-
from mock import MagicMock
5+
from unittest.mock import MagicMock
106

117

128
class TestRestyleMessage(TestCase):

tests/test_core/test_figure_messages/test_plotly_update.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import sys
21
from unittest import TestCase
32

43
import plotly.graph_objs as go
54
from plotly.basedatatypes import Undefined
65

7-
if sys.version_info >= (3, 3):
8-
from unittest.mock import MagicMock
9-
else:
10-
from mock import MagicMock
6+
from unittest.mock import MagicMock
117

128

139
class TestBatchUpdateMessage(TestCase):

0 commit comments

Comments
 (0)