77
88import numpy as np
99import pytest
10- from guidata .qthelpers import exec_dialog
10+ from guidata .qthelpers import exec_dialog , qt_app_context
1111from qtpy .QtCore import Qt
1212from qwt import QwtPlotCurve
1313
@@ -43,17 +43,19 @@ def _make_curve_style(shade, curvestyle, baseline):
4343@pytest .mark .parametrize ("baseline" , [0.0 ])
4444def test_builder_curve_curve_style (shade , curvestyle , baseline ):
4545 """Test curve parameters of curve() method"""
46- curve = _make_curve_style (shade , curvestyle , baseline )
47- show_items_qtbot ([curve ], "curve" )
46+ with qt_app_context (exec_loop = False ):
47+ curve = _make_curve_style (shade , curvestyle , baseline )
48+ show_items_qtbot ([curve ], "curve" )
4849
4950
5051@pytest .mark .parametrize ("shade" , [0 , 0.4 , 1.0 ])
5152@pytest .mark .parametrize ("curvestyle" , ["Lines" ])
5253@pytest .mark .parametrize ("baseline" , [0.0 , 1.0 ])
5354def test_builder_curve_curve_shade_baseline (shade , curvestyle , baseline ):
5455 """Test curve parameters of curve() method"""
55- curve = _make_curve_style (shade , curvestyle , baseline )
56- show_items_qtbot ([curve ], "curve" )
56+ with qt_app_context (exec_loop = False ):
57+ curve = _make_curve_style (shade , curvestyle , baseline )
58+ show_items_qtbot ([curve ], "curve" )
5759
5860
5961def _make_curve_dsamp (dsamp_factor , use_dsamp ):
@@ -70,16 +72,18 @@ def _make_curve_dsamp(dsamp_factor, use_dsamp):
7072@pytest .mark .parametrize ("use_dsamp" , [True ])
7173def test_builder_curve_dsamp_on (dsamp_factor , use_dsamp ):
7274 """Test downsampling parameters of curve() method: use_dsamp=True"""
73- curve = _make_curve_dsamp (dsamp_factor , use_dsamp )
74- show_items_qtbot ([curve ], "curve" )
75+ with qt_app_context (exec_loop = False ):
76+ curve = _make_curve_dsamp (dsamp_factor , use_dsamp )
77+ show_items_qtbot ([curve ], "curve" )
7578
7679
7780@pytest .mark .parametrize ("dsamp_factor" , [1 , 2 ])
7881@pytest .mark .parametrize ("use_dsamp" , [False ])
7982def test_builder_curve_dsamp_off (dsamp_factor , use_dsamp ):
8083 """Test downsampling parameters of curve() method: use_dsamp=False"""
81- curve = _make_curve_dsamp (dsamp_factor , use_dsamp )
82- show_items_qtbot ([curve ], "curve" )
84+ with qt_app_context (exec_loop = False ):
85+ curve = _make_curve_dsamp (dsamp_factor , use_dsamp )
86+ show_items_qtbot ([curve ], "curve" )
8387
8488
8589def _make_curve_linestyle (color , linestyle , linewidth ):
@@ -102,17 +106,19 @@ def _make_curve_linestyle(color, linestyle, linewidth):
102106@pytest .mark .parametrize ("linewidth" , [1 , 2 ])
103107def test_builder_curve_line_style (color , linestyle , linewidth ):
104108 """Test line parameters of curve() method"""
105- curve = _make_curve_linestyle (color , linestyle , linewidth )
106- show_items_qtbot ([curve ], "curve" )
109+ with qt_app_context (exec_loop = False ):
110+ curve = _make_curve_linestyle (color , linestyle , linewidth )
111+ show_items_qtbot ([curve ], "curve" )
107112
108113
109114@pytest .mark .parametrize ("color" , ["red" , "blue" ])
110115@pytest .mark .parametrize ("linestyle" , ["SolidLine" ])
111116@pytest .mark .parametrize ("linewidth" , [1 , 2 ])
112117def test_builder_curve_line_color (color , linestyle , linewidth ):
113118 """Test line parameters of curve() method"""
114- curve = _make_curve_linestyle (color , linestyle , linewidth )
115- show_items_qtbot ([curve ], "curve" )
119+ with qt_app_context (exec_loop = False ):
120+ curve = _make_curve_linestyle (color , linestyle , linewidth )
121+ show_items_qtbot ([curve ], "curve" )
116122
117123
118124def _make_curve_marker (marker , markersize , markerfacecolor , markeredgecolor ):
@@ -160,8 +166,9 @@ def test_builder_curve_marker_params_symbol(
160166 marker , markersize , markerfacecolor , markeredgecolor
161167):
162168 """Test marker parameters of curve() methodg"""
163- curve = _make_curve_marker (marker , markersize , markerfacecolor , markeredgecolor )
164- show_items_qtbot ([curve ], "curve" )
169+ with qt_app_context (exec_loop = False ):
170+ curve = _make_curve_marker (marker , markersize , markerfacecolor , markeredgecolor )
171+ show_items_qtbot ([curve ], "curve" )
165172
166173
167174@pytest .mark .parametrize ("marker" , ["Cross" ])
@@ -172,5 +179,6 @@ def test_builder_curve_marker_size_color(
172179 marker , markersize , markerfacecolor , markeredgecolor
173180):
174181 """Test marker parameters of curve() methodg"""
175- curve = _make_curve_marker (marker , markersize , markerfacecolor , markeredgecolor )
176- show_items_qtbot ([curve ], "curve" )
182+ with qt_app_context (exec_loop = False ):
183+ curve = _make_curve_marker (marker , markersize , markerfacecolor , markeredgecolor )
184+ show_items_qtbot ([curve ], "curve" )
0 commit comments