From 672b7740ab585c00fd5de55ada9ee0346802a3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Wed, 4 Nov 2026 19:04:28 +0100 Subject: [PATCH] tests: clear persistent upload jobs before and after each GUI test Each new main window restored the unfinished upload jobs of all previous GUI tests and uploaded them again. A slow or failing leftover upload then blocked the job the test was waiting for (e.g. test_gui_upload_private on Windows). Also print the 20 slowest tests in CI. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/check.yml | 2 +- CHANGELOG | 2 ++ tests/test_gui.py | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 83ec105..f95aacf 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -57,7 +57,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DCOR_API_KEY: ${{ secrets.DCOR_API_KEY }} run: | - coverage run --source=dcoraid -m pytest tests + coverage run --source=dcoraid -m pytest --durations=20 tests - name: Lint with flake8 run: | flake8 --exclude _version.py . diff --git a/CHANGELOG b/CHANGELOG index d67a4d9..fff1c0e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -66,6 +66,8 @@ - tests: replace tests that required access to the `figshare-import` circle with a circle, collection, and dataset shared by a second automatically created test user + - tests: clear persistent upload jobs before and after each GUI test, + so that new main windows do not upload jobs of previous tests again 1.1.3 - enh: use `HTTPAdapter` with `urlib3`'s `Retry` to handle connection issues - enh: use `requests.Session` when caching is disabled diff --git a/tests/test_gui.py b/tests/test_gui.py index 36db55f..560a24b 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -16,6 +16,7 @@ from PyQt6.QtWidgets import QInputDialog, QMessageBox from . import common +from .conftest import cleanup_dcoraid_tasks @pytest.fixture(scope="function", autouse=True) @@ -23,6 +24,18 @@ def clear_ckan_api(): dcoraid.gui.api._CKAN_API = None +@pytest.fixture(scope="function", autouse=True) +def clear_persistent_upload_jobs(): + """Start and end every GUI test with an empty persistent job list + + Otherwise, each new main window restores (and uploads again) the + unfinished upload jobs of all previous tests. + """ + cleanup_dcoraid_tasks() + yield + cleanup_dcoraid_tasks() + + @pytest.fixture def mw(qtbot): # Always set server correctly, because there is a test that