@@ -812,7 +812,7 @@ def check_cwd():
812
812
sys .platform .startswith ("linux" ) and running_in_ci (),
813
813
reason = 'Fails sometimes on Linux and CIs'
814
814
)
815
- @pytest .mark .skipif ( sys . platform == "darwin" , reason = "Fails sometimes on Mac" )
815
+ @pytest .mark .close_main_window
816
816
def test_dedicated_consoles (main_window , qtbot ):
817
817
"""Test running code in dedicated consoles."""
818
818
shell = main_window .ipyconsole .get_current_shellwidget ()
@@ -821,7 +821,7 @@ def test_dedicated_consoles(main_window, qtbot):
821
821
timeout = SHELL_TIMEOUT ,
822
822
)
823
823
824
- # ---- Load test file - ---
824
+ # --- Load test file ---
825
825
test_file = osp .join (LOCATION , 'script.py' )
826
826
main_window .editor .load (test_file )
827
827
code_editor = main_window .editor .get_focus_widget ()
@@ -914,7 +914,13 @@ def test_dedicated_consoles(main_window, qtbot):
914
914
# --- Assert runfile text is present after reruns ---
915
915
assert 'runfile' in control .toPlainText ()
916
916
917
- # ---- Closing test file and resetting config ----
917
+ # --- Assert no re-execution when already executing
918
+ shell .execute ("import time; time.sleep(5)" ) # Execute something long
919
+ qtbot .keyClick (code_editor , Qt .Key_F5 ) # Try to execute while busy
920
+ qtbot .wait (6000 ) # First exectution should be done
921
+ assert not shell .is_defined ("zz" ) # Second execution did not occur
922
+
923
+ # --- Closing test file and resetting config ---
918
924
main_window .editor .close_file ()
919
925
CONF .set ('run' , 'configurations' , {})
920
926
CONF .set ('run' , 'last_used_parameters_per_executor' , {})
@@ -1006,6 +1012,7 @@ def test_shell_execution(main_window, qtbot, tmpdir):
1006
1012
reason = "Fails frequently on Mac and CI" ,
1007
1013
)
1008
1014
@pytest .mark .order (after = "test_debug_unsaved_function" )
1015
+ @pytest .mark .close_main_window
1009
1016
def test_connection_to_external_kernel (main_window , qtbot ):
1010
1017
"""Test that only Spyder kernels are connected to the Variable Explorer."""
1011
1018
# Test with a generic kernel
@@ -1070,13 +1077,13 @@ def test_connection_to_external_kernel(main_window, qtbot):
1070
1077
shell .execute ('q' )
1071
1078
1072
1079
# Try quitting the kernels
1073
- shell .execute ('quit()' )
1074
- python_shell .execute ('quit()' )
1080
+ with qtbot .waitSignal (shell .executed ):
1081
+ shell .execute ('quit()' )
1082
+ with qtbot .waitSignal (python_shell .executed ):
1083
+ python_shell .execute ('quit()' )
1075
1084
1076
1085
# Make sure everything quit properly
1077
- qtbot .waitUntil (lambda : not km .is_alive ())
1078
1086
assert not km .is_alive ()
1079
- qtbot .waitUntil (lambda : not spykm .is_alive ())
1080
1087
assert not spykm .is_alive ()
1081
1088
1082
1089
# Close the channels
@@ -1198,6 +1205,7 @@ def test_change_cwd_explorer(main_window, qtbot, tmpdir, test_directory):
1198
1205
parse (ipy_release .version ) == parse ('7.11.0' )),
1199
1206
reason = "Hard to test on Windows and macOS and fails for IPython 7.11.0" )
1200
1207
@pytest .mark .order (after = "test_debug_unsaved_function" )
1208
+ @pytest .mark .close_main_window
1201
1209
def test_run_cython_code (main_window , qtbot ):
1202
1210
"""Test all the different ways we have to run Cython code"""
1203
1211
# Wait until the window is fully up
@@ -1217,6 +1225,7 @@ def test_run_cython_code(main_window, qtbot):
1217
1225
1218
1226
# Run file
1219
1227
qtbot .keyClick (code_editor , Qt .Key_F5 )
1228
+ qtbot .wait (1500 )
1220
1229
1221
1230
# Get a reference to the namespace browser widget
1222
1231
nsb = main_window .variableexplorer .current_widget ()
@@ -1240,6 +1249,7 @@ def test_run_cython_code(main_window, qtbot):
1240
1249
1241
1250
# Run file
1242
1251
qtbot .keyClick (code_editor , Qt .Key_F5 )
1252
+ qtbot .wait (500 )
1243
1253
1244
1254
# Wait until all objects have appeared in the variable explorer
1245
1255
qtbot .waitUntil (lambda : nsb .editor .source_model .rowCount () == 1 ,
0 commit comments