25
25
#==============================================================================
26
26
# Constants
27
27
#==============================================================================
28
+ # Location of this file
28
29
LOCATION = osp .realpath (osp .join (os .getcwd (), osp .dirname (__file__ )))
29
30
31
+ # Time to wait until the IPython console is ready to receive input
32
+ # (in miliseconds)
33
+ SHELL_TIMEOUT = 30000
34
+
35
+ # Time to wait for the IPython console to evaluate something (in
36
+ # miliseconds)
37
+ EVAL_TIMEOUT = 3000
38
+
30
39
31
40
#==============================================================================
32
41
# Utility functions
@@ -46,7 +55,7 @@ def open_file_in_editor(main_window, fname, directory=None):
46
55
def reset_run_code (qtbot , shell , code_editor , nsb ):
47
56
"""Reset state after a run code test"""
48
57
shell .execute ('%reset -f' )
49
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 0 , timeout = 1500 )
58
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 0 , timeout = EVAL_TIMEOUT )
50
59
code_editor .setFocus ()
51
60
qtbot .keyClick (code_editor , Qt .Key_Home , modifier = Qt .ControlModifier )
52
61
@@ -70,7 +79,7 @@ def test_run_code(main_window, qtbot):
70
79
# ---- Setup ----
71
80
# Wait until the window is fully up
72
81
shell = main_window .ipyconsole .get_current_shellwidget ()
73
- qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = 15000 )
82
+ qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = SHELL_TIMEOUT )
74
83
75
84
# Load test file
76
85
main_window .editor .load (osp .join (LOCATION , 'script.py' ))
@@ -87,7 +96,7 @@ def test_run_code(main_window, qtbot):
87
96
qtbot .keyClick (code_editor , Qt .Key_F5 )
88
97
89
98
# Wait until all objects have appeared in the variable explorer
90
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 3 , timeout = 1500 )
99
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 3 , timeout = EVAL_TIMEOUT )
91
100
92
101
# Verify result
93
102
assert shell .get_value ('a' ) == 10
@@ -103,7 +112,7 @@ def test_run_code(main_window, qtbot):
103
112
qtbot .wait (100 )
104
113
105
114
# Wait until all objects have appeared in the variable explorer
106
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 3 , timeout = 1500 )
115
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 3 , timeout = EVAL_TIMEOUT )
107
116
108
117
# Verify result
109
118
assert shell .get_value ('a' ) == 10
@@ -119,7 +128,7 @@ def test_run_code(main_window, qtbot):
119
128
qtbot .wait (100 )
120
129
121
130
# Wait until all objects have appeared in the variable explorer
122
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 3 , timeout = 1500 )
131
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 3 , timeout = EVAL_TIMEOUT )
123
132
124
133
# Verify result
125
134
assert shell .get_value ('a' ) == 10
@@ -133,7 +142,7 @@ def test_run_code(main_window, qtbot):
133
142
qtbot .keyClick (code_editor , Qt .Key_Return , modifier = Qt .ControlModifier )
134
143
135
144
# Wait until the object has appeared in the variable explorer
136
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 1 , timeout = 1500 )
145
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 1 , timeout = EVAL_TIMEOUT )
137
146
138
147
# Verify result
139
148
assert shell .get_value ('a' ) == 10
@@ -146,7 +155,7 @@ def test_run_code(main_window, qtbot):
146
155
main_window .close ()
147
156
148
157
149
- @pytest .mark .skipif (os .name == 'nt' , reason = "It's timing out sometimes on Windows" )
158
+ @pytest .mark .skipif (os .name == 'nt' , reason = "It times out sometimes on Windows" )
150
159
def test_open_files_in_new_editor_window (main_window , qtbot ):
151
160
"""
152
161
This tests that opening files in a new editor window
@@ -156,7 +165,7 @@ def test_open_files_in_new_editor_window(main_window, qtbot):
156
165
"""
157
166
# Wait until the window is fully up
158
167
shell = main_window .ipyconsole .get_current_shellwidget ()
159
- qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = 15000 )
168
+ qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = SHELL_TIMEOUT )
160
169
161
170
# Set a timer to manipulate the open dialog while it's running
162
171
QTimer .singleShot (2000 , lambda : open_file_in_editor (main_window ,
@@ -180,7 +189,7 @@ def test_maximize_minimize_plugins(main_window, qtbot):
180
189
"""Test that the maximize button is working correctly."""
181
190
# Wait until the window is fully up
182
191
shell = main_window .ipyconsole .get_current_shellwidget ()
183
- qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = 15000 )
192
+ qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = SHELL_TIMEOUT )
184
193
185
194
# Set focus to the Editor
186
195
main_window .editor .get_focus_widget ().setFocus ()
@@ -200,6 +209,7 @@ def test_maximize_minimize_plugins(main_window, qtbot):
200
209
main_window .close ()
201
210
202
211
212
+ @pytest .mark .skipif (os .name == 'nt' , reason = "It times out sometimes on Windows" )
203
213
def test_issue_4066 (main_window , qtbot ):
204
214
"""
205
215
Test for a segfault when these steps are followed:
@@ -211,12 +221,12 @@ def test_issue_4066(main_window, qtbot):
211
221
"""
212
222
# Create the object
213
223
shell = main_window .ipyconsole .get_current_shellwidget ()
214
- qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = 15000 )
224
+ qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = SHELL_TIMEOUT )
215
225
shell .execute ('myobj = [1, 2, 3]' )
216
226
217
227
# Open editor associated with that object and get a reference to it
218
228
nsb = main_window .variableexplorer .get_focus_widget ()
219
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () > 0 , timeout = 1500 )
229
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () > 0 , timeout = EVAL_TIMEOUT )
220
230
nsb .editor .setFocus ()
221
231
nsb .editor .edit_item ()
222
232
obj_editor_id = list (nsb .editor .delegate ._editors .keys ())[0 ]
@@ -225,13 +235,14 @@ def test_issue_4066(main_window, qtbot):
225
235
# Move to the IPython console and delete that object
226
236
main_window .ipyconsole .get_focus_widget ().setFocus ()
227
237
shell .execute ('del myobj' )
228
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 0 , timeout = 1500 )
238
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () == 0 , timeout = EVAL_TIMEOUT )
229
239
230
240
# Close editor
231
241
ok_widget = obj_editor .bbox .button (obj_editor .bbox .Ok )
232
242
qtbot .mouseClick (ok_widget , Qt .LeftButton )
233
243
234
244
245
+ @pytest .mark .skipif (os .name == 'nt' , reason = "It times out sometimes on Windows" )
235
246
def test_varexp_edit_inline (main_window , qtbot ):
236
247
"""
237
248
Test for errors when editing inline values in the Variable Explorer
@@ -243,13 +254,13 @@ def test_varexp_edit_inline(main_window, qtbot):
243
254
"""
244
255
# Create object
245
256
shell = main_window .ipyconsole .get_current_shellwidget ()
246
- qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = 15000 )
257
+ qtbot .waitUntil (lambda : shell ._prompt_html is not None , timeout = SHELL_TIMEOUT )
247
258
shell .execute ('a = 10' )
248
259
249
260
# Edit object
250
261
main_window .variableexplorer .visibility_changed (True )
251
262
nsb = main_window .variableexplorer .get_focus_widget ()
252
- qtbot .waitUntil (lambda : nsb .editor .model .rowCount () > 0 , timeout = 1500 )
263
+ qtbot .waitUntil (lambda : nsb .editor .model .rowCount () > 0 , timeout = EVAL_TIMEOUT )
253
264
nsb .editor .setFocus ()
254
265
nsb .editor .edit_item ()
255
266
0 commit comments