diff --git a/conftest.py b/conftest.py index a1aa82e37..20d7a402b 100644 --- a/conftest.py +++ b/conftest.py @@ -90,7 +90,8 @@ def generate_initial_config(): examples = DataFiles(data_fs=constants.DATA_FS, server_config_fs=constants.SERVER_CONFIG_FS) examples.create_server_config(detailed_information=True) - examples.create_data() + if constants.DATA_FS.isempty("/"): + examples.create_data() if not constants.SERVER_CONFIG_FS.exists(constants.MSCOLAB_CONFIG_FILE): config_string = f''' @@ -220,9 +221,15 @@ def reset_config(): """Reset the configuration directory used in the tests (tests.constants.ROOT_FS) after every test """ # Ideally this would just be constants.ROOT_FS.removetree("/"), but SQLAlchemy complains if the SQLite file is deleted. + # Also, on Windows there are issues with files in msui/testdata being held open in another process, so those are + # excluded as well. This shouldn't be a problem since they are meant to be static anyway. for e in constants.ROOT_FS.walk.files(exclude=["mscolab.db"]): + if fs.path.isbase("/msui/testdata", e): + continue constants.ROOT_FS.remove(e) for e in constants.ROOT_FS.walk.dirs(search="depth"): + if e == "/msui" or fs.path.isbase("/msui/testdata", e): + continue constants.ROOT_FS.removedir(e) generate_initial_config() diff --git a/tests/_test_msui/test_linearview.py b/tests/_test_msui/test_linearview.py index 848f40d4c..91752725d 100644 --- a/tests/_test_msui/test_linearview.py +++ b/tests/_test_msui/test_linearview.py @@ -117,5 +117,5 @@ def test_server_getmap(self, qtbot): assert that a getmap call to a WMS server displays an image """ self.query_server(self.url) - with qtbot.wait_signal(self.wms_control.image_displayed): + with qtbot.wait_signal(self.wms_control.image_displayed, timeout=30000): QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton) diff --git a/tests/_test_msui/test_mscolab.py b/tests/_test_msui/test_mscolab.py index 49a9f0992..0b949629c 100644 --- a/tests/_test_msui/test_mscolab.py +++ b/tests/_test_msui/test_mscolab.py @@ -25,6 +25,7 @@ limitations under the License. """ import os +import sys import fs import fs.errors import fs.opener.errors @@ -350,6 +351,10 @@ def test_handle_export(self, mockbox, qtbot): for i in range(wp_count): assert exported_waypoints.waypoint_data(i).lat == self.window.mscolab.waypoints_model.waypoint_data(i).lat + @pytest.mark.skipif( + sys.platform != "darwin", + reason="This is flaky on MacOS because of some cleanup error in temporary files.", + ) @pytest.mark.parametrize("name", [("example.ftml", "actionImportFlightTrackFTML", 5), ("example.csv", "actionImportFlightTrackCSV", 5), ("example.txt", "actionImportFlightTrackTXT", 5), diff --git a/tests/_test_msui/test_sideview.py b/tests/_test_msui/test_sideview.py index 0201862bf..de052bb74 100644 --- a/tests/_test_msui/test_sideview.py +++ b/tests/_test_msui/test_sideview.py @@ -157,7 +157,7 @@ def test_server_getmap(self, qtbot): assert that a getmap call to a WMS server displays an image """ self.query_server(self.url) - with qtbot.wait_signal(self.wms_control.image_displayed): + with qtbot.wait_signal(self.wms_control.image_displayed, timeout=30000): QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton) assert self.window.getView().plotter.image is not None diff --git a/tests/_test_msui/test_topview.py b/tests/_test_msui/test_topview.py index f939281d7..0b4920b81 100644 --- a/tests/_test_msui/test_topview.py +++ b/tests/_test_msui/test_topview.py @@ -227,13 +227,13 @@ def query_server(self, url): QtTest.QTest.mouseClick(self.wms_control.multilayers.btGetCapabilities, QtCore.Qt.LeftButton) wait_until_signal(self.wms_control.cpdlg.canceled) - def test_server_getmap(self): + def test_server_getmap(self, qtbot): """ assert that a getmap call to a WMS server displays an image """ self.query_server(self.url) - QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton) - wait_until_signal(self.wms_control.image_displayed) + with qtbot.wait_signal(self.wms_control.image_displayed, timeout=30000): + QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton) assert self.window.getView().map.image is not None self.window.getView().set_settings({}) self.window.getView().clear_figure() diff --git a/tests/_test_msui/test_wms_control.py b/tests/_test_msui/test_wms_control.py index afe84783f..8dea2ca06 100644 --- a/tests/_test_msui/test_wms_control.py +++ b/tests/_test_msui/test_wms_control.py @@ -182,7 +182,7 @@ def test_server_getmap(self, qtbot): """ self.query_server(self.url) - with qtbot.wait_signal(self.window.image_displayed): + with qtbot.wait_signal(self.window.image_displayed, timeout=30000): QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton) assert self.view.draw_image.call_count == 1 @@ -195,7 +195,7 @@ def test_server_getmap_cached(self, qtbot): """ self.query_server(self.url) - with qtbot.wait_signal(self.window.image_displayed): + with qtbot.wait_signal(self.window.image_displayed, timeout=30000): QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton) assert self.view.draw_image.call_count == 1 @@ -421,7 +421,7 @@ def test_server_getmap(self, qtbot): assert that a getmap call to a WMS server displays an image """ self.query_server(self.url) - with qtbot.wait_signal(self.window.image_displayed): + with qtbot.wait_signal(self.window.image_displayed, timeout=30000): QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton) assert self.view.draw_image.call_count == 1