7
7
8
8
import numpy as np
9
9
import pytest
10
- from guidata .qthelpers import exec_dialog
10
+ from guidata .qthelpers import exec_dialog , qt_app_context
11
11
from qtpy .QtCore import Qt
12
12
from qwt import QwtPlotCurve
13
13
@@ -43,17 +43,19 @@ def _make_curve_style(shade, curvestyle, baseline):
43
43
@pytest .mark .parametrize ("baseline" , [0.0 ])
44
44
def test_builder_curve_curve_style (shade , curvestyle , baseline ):
45
45
"""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" )
48
49
49
50
50
51
@pytest .mark .parametrize ("shade" , [0 , 0.4 , 1.0 ])
51
52
@pytest .mark .parametrize ("curvestyle" , ["Lines" ])
52
53
@pytest .mark .parametrize ("baseline" , [0.0 , 1.0 ])
53
54
def test_builder_curve_curve_shade_baseline (shade , curvestyle , baseline ):
54
55
"""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" )
57
59
58
60
59
61
def _make_curve_dsamp (dsamp_factor , use_dsamp ):
@@ -70,16 +72,18 @@ def _make_curve_dsamp(dsamp_factor, use_dsamp):
70
72
@pytest .mark .parametrize ("use_dsamp" , [True ])
71
73
def test_builder_curve_dsamp_on (dsamp_factor , use_dsamp ):
72
74
"""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" )
75
78
76
79
77
80
@pytest .mark .parametrize ("dsamp_factor" , [1 , 2 ])
78
81
@pytest .mark .parametrize ("use_dsamp" , [False ])
79
82
def test_builder_curve_dsamp_off (dsamp_factor , use_dsamp ):
80
83
"""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" )
83
87
84
88
85
89
def _make_curve_linestyle (color , linestyle , linewidth ):
@@ -102,17 +106,19 @@ def _make_curve_linestyle(color, linestyle, linewidth):
102
106
@pytest .mark .parametrize ("linewidth" , [1 , 2 ])
103
107
def test_builder_curve_line_style (color , linestyle , linewidth ):
104
108
"""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" )
107
112
108
113
109
114
@pytest .mark .parametrize ("color" , ["red" , "blue" ])
110
115
@pytest .mark .parametrize ("linestyle" , ["SolidLine" ])
111
116
@pytest .mark .parametrize ("linewidth" , [1 , 2 ])
112
117
def test_builder_curve_line_color (color , linestyle , linewidth ):
113
118
"""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" )
116
122
117
123
118
124
def _make_curve_marker (marker , markersize , markerfacecolor , markeredgecolor ):
@@ -160,8 +166,9 @@ def test_builder_curve_marker_params_symbol(
160
166
marker , markersize , markerfacecolor , markeredgecolor
161
167
):
162
168
"""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" )
165
172
166
173
167
174
@pytest .mark .parametrize ("marker" , ["Cross" ])
@@ -172,5 +179,6 @@ def test_builder_curve_marker_size_color(
172
179
marker , markersize , markerfacecolor , markeredgecolor
173
180
):
174
181
"""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