Skip to content

Commit

Permalink
Fix the weird issue in run monitor test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhe-slac committed Jan 28, 2025
1 parent 3b3cc03 commit c30c08b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
7 changes: 5 additions & 2 deletions src/badger/gui/default/components/routine_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,11 @@ def check_queue(self) -> None:
self.routine.generator = results[1]

if not self.data_and_error_queue.empty():
error_title, error_traceback = self.data_and_error_queue.get()
BadgerError(error_title, error_traceback)
try:
error_title, error_traceback = self.data_and_error_queue.get()
BadgerError(error_title, error_traceback)
except ValueError: # seems to only occur in tests
pass

if not self.routine_process.is_alive():
self.close()
Expand Down
19 changes: 3 additions & 16 deletions src/badger/tests/test_run_monitor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import multiprocessing
import time
import warnings
from unittest.mock import patch

import numpy as np
import pytest
from PyQt5.QtCore import QEventLoop, QPointF, Qt, QTimer
from PyQt5.QtGui import QMouseEvent
from PyQt5.QtTest import QSignalSpy, QTest
from PyQt5.QtTest import QSignalSpy
from PyQt5.QtWidgets import QApplication, QMessageBox


Expand Down Expand Up @@ -114,20 +113,8 @@ def test_run_monitor(self, process_manager):
assert spy.isValid()
monitor.start()

def test_routine_identity(self, qtbot, process_manager, init_multiprocessing):
from badger.archive import save_tmp_run
from badger.gui.default.components.run_monitor import BadgerOptMonitor
from badger.tests.utils import create_routine

monitor = BadgerOptMonitor(process_manager)
# qtbot.addWidget(monitor)

routine = create_routine()
tmp_filename = save_tmp_run(routine)

# Feed in the sample routine
monitor.routine = routine
monitor.routine_filename = tmp_filename
def test_routine_identity(self, home_page):
monitor = home_page.run_monitor
monitor.init_routine_runner()

assert monitor.routine_runner.routine == monitor.routine
Expand Down

0 comments on commit c30c08b

Please sign in to comment.