Skip to content

Commit

Permalink
Fix hanging integration tests (#515)
Browse files Browse the repository at this point in the history
* fix workflow presenter to run things from threads

* fix use of requests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add annotations to handleAction for callable

* minor change

* reduce number of cylinders for faster raw vanadium

* remove commented-out lines

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
rboston628 and pre-commit-ci[bot] authored Dec 6, 2024
1 parent 3ce593e commit 0601ba0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
4 changes: 4 additions & 0 deletions tests/resources/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ IPTS:
constants:
# For tests with '46680' this seems to be necessary.
maskedPixelThreshold: 1.0

RawVanadiumCorrection:
numberOfSlices: 1
numberOfAnnuli: 1
25 changes: 0 additions & 25 deletions tests/unit/ui/workflow/test_DiffCalWorkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
GroupWorkspaces,
mtd,
)
from qtpy.QtWidgets import QMessageBox

from snapred.meta.mantid.FitPeaksOutput import FIT_PEAK_DIAG_SUFFIX, FitOutputEnum
from snapred.meta.pointer import create_pointer
Expand Down Expand Up @@ -164,29 +163,5 @@ def test_purge_bad_peaks_too_few(workflowRequest, qtbot): # noqa: ARG001
with pytest.raises(RuntimeError):
diffcalWorkflow._purgeBadPeaks(maxChiSq)

# setup the qtbot to intercept the window
qtbot.addWidget(diffcalWorkflow._tweakPeakView)

#
# Using a mock here bypasses the following issues:
#
# * which thread the messagebox will be running on (may cause a segfault);
#
# * how long to wait for the messagebox to instantiate.
#
def _tooFewPeaksQuery(_parent, title, text, _buttons):
if title == "Too Few Peaks":
return QMessageBox.Ok
raise RuntimeError(f"unexpected `QMessageBox.critical`: title: {title}, text: {text}")

mockTooFewPeaksQuery = patch("qtpy.QtWidgets.QMessageBox.critical", _tooFewPeaksQuery)

# Use `start` and `stop` rather than `with patch...` in order to apply the mock even in the case of exceptions.
mockTooFewPeaksQuery.start()
diffcalWorkflow.purgeBadPeaks(maxChiSq)

# Remember to remove the mock.
mockTooFewPeaksQuery.stop()

assert diffcalWorkflow.ingredients.groupedPeakLists[0].peaks == peaks
assert diffcalWorkflow.ingredients.groupedPeakLists[0].peaks != good_peaks

0 comments on commit 0601ba0

Please sign in to comment.