77
88import numpy as np
99import pytest
10+ from guidata .qthelpers import exec_dialog
1011from qtpy .QtCore import Qt
1112from qwt import QwtPlotCurve
1213
1314from 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
5959def _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
8585def _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
118118def _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" ])
159159def 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" ])
171171def 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" )
0 commit comments