mantidproject / mantidimaging

Graphical toolkit for neutron imaging.
https://mantidproject.github.io/mantidimaging
GNU General Public License v3.0
13 stars 6 forks source link

test_replace_image_stack fails with Could not find button #2333

Closed samtygier-stfc closed 1 week ago

samtygier-stfc commented 1 week ago

Summary

TestGuiSystemLoading::test_replace_image_stack sometimes fails with:

AssertionError
ERROR    mantidimaging.gui.mvp_base.view:view.py:46 show_error_dialog(): 
Traceback (most recent call last):
  File "/home/sam/git/mantidimaging/mantidimaging/gui/windows/main/presenter.py", line 99, in notify
    self._add_images_to_existing_dataset()
  File "/home/sam/git/mantidimaging/mantidimaging/gui/windows/main/presenter.py", line 745, in _add_images_to_existing_dataset
    assert dataset is not None
           ^^^^^^^^^^^^^^^^^^^
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sam/git/mantidimaging/mantidimaging/gui/test/gui_system_base.py", line 46, in <lambda>
    QTimer.singleShot(SHORT_DELAY, lambda: self._click_messageBox("Yes"))
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sam/git/mantidimaging/mantidimaging/gui/test/gui_system_base.py", line 70, in _click_messageBox
    raise ValueError(f"Could not find button '{button_text}' in {button_texts}.\n"
ValueError: Could not find button 'Yes' in ['&OK'].
Message box: Error

It is looking for the "Are you sure you want to quit with loaded data?" dialog from the tearDown, but instead finding an error box due to the assert in _add_images_to_existing_dataset

Steps To Reproduce

Run the system test many times: xvfb-run --auto-servernum python -m pytest -vs -rs -p no:xdist -p no:randomly -p no:repeat -p no:cov -o log_cli=true --run-system-tests mantidimaging/gui/test/ -k TestGuiSystemLoading

Can be made more common by removing QTest.qWait(SHORT_DELAY) from the end of the the test

Expected Behaviour

Test should always pass

Current Behaviour

Occasional fails

Context

Current main