Skip to content

Commit fb949f5

Browse files
committed
Removed pytest-qt features
(compatibility issues with Qt6)
1 parent ae7d792 commit fb949f5

File tree

7 files changed

+73
-79
lines changed

7 files changed

+73
-79
lines changed

plotpy/tests/unit/test_builder_annotation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _make_annotation(
6060
make.annotated_ellipse,
6161
],
6262
)
63-
def test_builder_annotation_params(qtbot, method):
63+
def test_builder_annotation_params(method):
6464
items = []
6565
for show_label in [True, False]:
6666
items.append(
@@ -85,4 +85,4 @@ def test_builder_annotation_params(qtbot, method):
8585
items.append(_make_annotation(method, readonly=readonly))
8686
for private in [True, False]:
8787
items.append(_make_annotation(method, private=private))
88-
show_items_qtbot(qtbot, items)
88+
show_items_qtbot(items)

plotpy/tests/unit/test_builder_curve.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
import numpy as np
99
import pytest
10+
from guidata.qthelpers import exec_dialog
1011
from qtpy.QtCore import Qt
1112
from qwt import QwtPlotCurve
1213

1314
from plotpy.builder import make
1415

1516

16-
def show_items_qtbot(qtbot, items, type="curve"):
17+
def show_items_qtbot(items, type="curve"):
1718
"""Plot curve in a dialog"""
1819
win = make.dialog(type=type)
1920
plot = win.manager.get_plot()
2021
for item in items:
2122
plot.add_item(item)
22-
win.show()
23-
qtbot.keyClick(win, Qt.Key_Enter)
23+
exec_dialog(win)
2424

2525

2626
_COLOR_TO_HEX = {"red": "#ff0000", "blue": "#0000ff"}
@@ -41,19 +41,19 @@ def _make_curve_style(shade, curvestyle, baseline):
4141
@pytest.mark.parametrize("shade", [0])
4242
@pytest.mark.parametrize("curvestyle", ["Lines", "Sticks", "Steps", "Dots", "NoCurve"])
4343
@pytest.mark.parametrize("baseline", [0.0])
44-
def test_builder_curve_curve_style(qtbot, shade, curvestyle, baseline):
44+
def test_builder_curve_curve_style(shade, curvestyle, baseline):
4545
"""Test curve parameters of curve() method"""
4646
curve = _make_curve_style(shade, curvestyle, baseline)
47-
show_items_qtbot(qtbot, [curve], "curve")
47+
show_items_qtbot([curve], "curve")
4848

4949

5050
@pytest.mark.parametrize("shade", [0, 0.4, 1.0])
5151
@pytest.mark.parametrize("curvestyle", ["Lines"])
5252
@pytest.mark.parametrize("baseline", [0.0, 1.0])
53-
def test_builder_curve_curve_shade_baseline(qtbot, shade, curvestyle, baseline):
53+
def test_builder_curve_curve_shade_baseline(shade, curvestyle, baseline):
5454
"""Test curve parameters of curve() method"""
5555
curve = _make_curve_style(shade, curvestyle, baseline)
56-
show_items_qtbot(qtbot, [curve], "curve")
56+
show_items_qtbot([curve], "curve")
5757

5858

5959
def _make_curve_dsamp(dsamp_factor, use_dsamp):
@@ -68,18 +68,18 @@ def _make_curve_dsamp(dsamp_factor, use_dsamp):
6868

6969
@pytest.mark.parametrize("dsamp_factor", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 30, 50])
7070
@pytest.mark.parametrize("use_dsamp", [True])
71-
def test_builder_curve_dsamp_on(qtbot, dsamp_factor, use_dsamp):
71+
def test_builder_curve_dsamp_on(dsamp_factor, use_dsamp):
7272
"""Test downsampling parameters of curve() method: use_dsamp=True"""
7373
curve = _make_curve_dsamp(dsamp_factor, use_dsamp)
74-
show_items_qtbot(qtbot, [curve], "curve")
74+
show_items_qtbot([curve], "curve")
7575

7676

7777
@pytest.mark.parametrize("dsamp_factor", [1, 2])
7878
@pytest.mark.parametrize("use_dsamp", [False])
79-
def test_builder_curve_dsamp_off(qtbot, dsamp_factor, use_dsamp):
79+
def test_builder_curve_dsamp_off(dsamp_factor, use_dsamp):
8080
"""Test downsampling parameters of curve() method: use_dsamp=False"""
8181
curve = _make_curve_dsamp(dsamp_factor, use_dsamp)
82-
show_items_qtbot(qtbot, [curve], "curve")
82+
show_items_qtbot([curve], "curve")
8383

8484

8585
def _make_curve_linestyle(color, linestyle, linewidth):
@@ -100,19 +100,19 @@ def _make_curve_linestyle(color, linestyle, linewidth):
100100
["SolidLine", "DashLine", "DotLine", "DashDotLine", "DashDotDotLine", "NoPen"],
101101
)
102102
@pytest.mark.parametrize("linewidth", [1, 2])
103-
def test_builder_curve_line_style(qtbot, color, linestyle, linewidth):
103+
def test_builder_curve_line_style(color, linestyle, linewidth):
104104
"""Test line parameters of curve() method"""
105105
curve = _make_curve_linestyle(color, linestyle, linewidth)
106-
show_items_qtbot(qtbot, [curve], "curve")
106+
show_items_qtbot([curve], "curve")
107107

108108

109109
@pytest.mark.parametrize("color", ["red", "blue"])
110110
@pytest.mark.parametrize("linestyle", ["SolidLine"])
111111
@pytest.mark.parametrize("linewidth", [1, 2])
112-
def test_builder_curve_line_color(qtbot, color, linestyle, linewidth):
112+
def test_builder_curve_line_color(color, linestyle, linewidth):
113113
"""Test line parameters of curve() method"""
114114
curve = _make_curve_linestyle(color, linestyle, linewidth)
115-
show_items_qtbot(qtbot, [curve], "curve")
115+
show_items_qtbot([curve], "curve")
116116

117117

118118
def _make_curve_marker(marker, markersize, markerfacecolor, markeredgecolor):
@@ -157,20 +157,20 @@ def _make_curve_marker(marker, markersize, markerfacecolor, markeredgecolor):
157157
@pytest.mark.parametrize("markerfacecolor", ["red"])
158158
@pytest.mark.parametrize("markeredgecolor", ["blue"])
159159
def test_builder_curve_marker_params_symbol(
160-
qtbot, marker, markersize, markerfacecolor, markeredgecolor
160+
marker, markersize, markerfacecolor, markeredgecolor
161161
):
162162
"""Test marker parameters of curve() methodg"""
163163
curve = _make_curve_marker(marker, markersize, markerfacecolor, markeredgecolor)
164-
show_items_qtbot(qtbot, [curve], "curve")
164+
show_items_qtbot([curve], "curve")
165165

166166

167167
@pytest.mark.parametrize("marker", ["Cross"])
168168
@pytest.mark.parametrize("markersize", [1, 5, 10])
169169
@pytest.mark.parametrize("markerfacecolor", ["red", "blue"])
170170
@pytest.mark.parametrize("markeredgecolor", ["red", "blue"])
171171
def test_builder_curve_marker_size_color(
172-
qtbot, marker, markersize, markerfacecolor, markeredgecolor
172+
marker, markersize, markerfacecolor, markeredgecolor
173173
):
174174
"""Test marker parameters of curve() methodg"""
175175
curve = _make_curve_marker(marker, markersize, markerfacecolor, markeredgecolor)
176-
show_items_qtbot(qtbot, [curve], "curve")
176+
show_items_qtbot([curve], "curve")

plotpy/tests/unit/test_builder_image.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,56 +59,56 @@ def _make_image(
5959
LUTAlpha.TANH,
6060
],
6161
)
62-
def test_builder_image_alpha_function(qtbot, alpha_function):
62+
def test_builder_image_alpha_function(alpha_function):
6363
item = _make_image(alpha_function=alpha_function)
64-
show_items_qtbot(qtbot, [item])
64+
show_items_qtbot([item])
6565

6666

6767
@pytest.mark.parametrize(
6868
"xdata,ydata", [[[None, None], [None, None]], [[-10, 10], [-10, 10]]]
6969
)
70-
def test_builder_image_xdata_ydata(qtbot, xdata, ydata):
70+
def test_builder_image_xdata_ydata(xdata, ydata):
7171
item = _make_image(xdata=xdata, ydata=ydata)
72-
show_items_qtbot(qtbot, [item])
72+
show_items_qtbot([item])
7373

7474

7575
@pytest.mark.parametrize("pixel_size", [None, 1.0, (1.0, 2.0)])
76-
def test_builder_image_pixel_size(qtbot, pixel_size):
76+
def test_builder_image_pixel_size(pixel_size):
7777
item = _make_image(pixel_size=pixel_size)
78-
show_items_qtbot(qtbot, [item])
78+
show_items_qtbot([item])
7979

8080

8181
@pytest.mark.parametrize("center_on", [None, [1.0, 3.0]])
82-
def test_builder_image_center_on(qtbot, center_on):
82+
def test_builder_image_center_on(center_on):
8383
item = _make_image(center_on=center_on, pixel_size=(1.0, 1.0))
84-
show_items_qtbot(qtbot, [item])
84+
show_items_qtbot([item])
8585

8686

8787
@pytest.mark.parametrize("interpolation", ["nearest", "linear", "antialiasing"])
88-
def test_builder_image_interpolation(qtbot, interpolation):
88+
def test_builder_image_interpolation(interpolation):
8989
item = _make_image(interpolation=interpolation)
90-
show_items_qtbot(qtbot, [item])
90+
show_items_qtbot([item])
9191

9292

9393
@pytest.mark.parametrize("background_color", [None, "red"])
94-
def test_builder_image_background_color(qtbot, background_color):
94+
def test_builder_image_background_color(background_color):
9595
item = _make_image(background_color=background_color)
96-
show_items_qtbot(qtbot, [item])
96+
show_items_qtbot([item])
9797

9898

9999
@pytest.mark.parametrize("eliminate_outliers", [None, 3.0])
100-
def test_builder_image_eliminate_outliers(qtbot, eliminate_outliers):
100+
def test_builder_image_eliminate_outliers(eliminate_outliers):
101101
item = _make_image(eliminate_outliers=eliminate_outliers)
102-
show_items_qtbot(qtbot, [item])
102+
show_items_qtbot([item])
103103

104104

105105
@pytest.mark.parametrize("lut_range", [None, [0.0, 100.0]])
106-
def test_builder_image_lut_range(qtbot, lut_range):
106+
def test_builder_image_lut_range(lut_range):
107107
item = _make_image(lut_range=lut_range)
108-
show_items_qtbot(qtbot, [item])
108+
show_items_qtbot([item])
109109

110110

111111
@pytest.mark.parametrize("lock_position", [None, True, False])
112-
def test_builder_image_lock_position(qtbot, lock_position):
112+
def test_builder_image_lock_position(lock_position):
113113
item = _make_image(lock_position=lock_position)
114-
show_items_qtbot(qtbot, [item])
114+
show_items_qtbot([item])

plotpy/tests/unit/test_builder_shape.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ def _make_standard_shape(
3636
"method",
3737
[make.segment, make.rectangle, make.circle, make.ellipse],
3838
)
39-
def test_builder_standard_shape(qtbot, method):
39+
def test_builder_standard_shape(method):
4040
items = []
4141
items.append(_make_standard_shape(method, title="title"))
42-
show_items_qtbot(qtbot, items)
42+
show_items_qtbot(items)
4343

4444

45-
def test_builder_polygon(qtbot):
45+
def test_builder_polygon():
4646
items = []
4747
x = np.linspace(0, 1, 10)
4848
y = x**2
4949
for closed in [True, False]:
5050
items.append(make.polygon(x, y, closed=closed, title="title"))
51-
show_items_qtbot(qtbot, items)
51+
show_items_qtbot(items)
5252

5353

54-
def test_builder_svgshape(qtbot):
54+
def test_builder_svgshape():
5555
items = []
5656
svg_path = get_path("svg_target.svg")
5757
with open(svg_path, "rb") as f:
@@ -63,4 +63,4 @@ def test_builder_svgshape(qtbot):
6363
items.append(
6464
make.svg(shape_str, data_or_path, 0.0, 0.0, 1.0, 1.0, title="title")
6565
)
66-
show_items_qtbot(qtbot, items)
66+
show_items_qtbot(items)

plotpy/tests/unit/test_plot_curve.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""Test plotting of a curve with PlotDialog"""
77

88
import numpy as np
9-
from qtpy.QtCore import Qt
9+
from guidata.qthelpers import exec_dialog
1010
from qwt import QwtPlotItem
1111

1212
from plotpy.builder import make
@@ -19,7 +19,7 @@
1919
)
2020

2121

22-
def test_plot_curve(qtbot):
22+
def test_plot_curve():
2323
"""Test plotting of a curve with PlotDialog"""
2424

2525
x = np.linspace(-10, 10, 200)
@@ -31,7 +31,6 @@ def test_plot_curve(qtbot):
3131
plot = win.manager.get_plot()
3232
plot.add_item(curve)
3333

34-
qtbot.addWidget(win)
3534
win.show()
3635

3736
assert isinstance(win.plot_widget, PlotWidget)
@@ -47,10 +46,10 @@ def test_plot_curve(qtbot):
4746
tool = win.manager.get_tool(curve_tool_class)
4847
assert tool is not None, f"Tool of type {curve_tool_class} not found"
4948

50-
qtbot.keyClick(win, Qt.Key_Enter)
49+
exec_dialog(win)
5150

5251

53-
def test_plot_curve_anti_aliasing(qtbot):
52+
def test_plot_curve_anti_aliasing():
5453
"""Test Anti-aliasing tool"""
5554

5655
x = np.linspace(-10, 10, 200)
@@ -61,7 +60,6 @@ def test_plot_curve_anti_aliasing(qtbot):
6160
plot = win.manager.get_plot()
6261
plot.add_item(curve)
6362

64-
qtbot.addWidget(win)
6563
win.show()
6664

6765
assert isinstance(win.plot_widget, PlotWidget)
@@ -86,4 +84,4 @@ def test_plot_curve_anti_aliasing(qtbot):
8684
aliased_img = plot.grab().toImage()
8785
assert original_img == aliased_img
8886

89-
qtbot.keyClick(win, Qt.Key_Enter)
87+
exec_dialog(win)

0 commit comments

Comments
 (0)