Skip to content

Commit

Permalink
TST: Add test case to verify reloading the main window re-compiles th…
Browse files Browse the repository at this point in the history
…e underlying ui files
  • Loading branch information
jbellister-slac committed Feb 10, 2024
1 parent 1d78dd6 commit cacba85
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pydm/tests/test_main_window.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os

from pydm import Display, PyDMApplication
from qtpy import uic
from unittest.mock import MagicMock, patch

# The path to the .ui file for creating a main window
test_ui_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_data", "test.ui")


@patch("qtpy.uic.compileUi", wraps=uic.compileUi)
def test_reload_display(wrapped_compile_ui: MagicMock, qapp: PyDMApplication) -> None:
"""Verify that when a user reloads a PyDM window the underling display's ui file is actually reloaded"""
display = Display(parent=None, ui_filename=test_ui_path)

qapp.make_main_window()
qapp.main_window.set_display_widget(display)

# When the display is first created and loaded the underlying ui file gets compiled
wrapped_compile_ui.assert_called_once()

# Reloading should force a re-compile of the ui file to ensure any changes are picked up
qapp.main_window.reload_display(True)
assert wrapped_compile_ui.call_count == 2

0 comments on commit cacba85

Please sign in to comment.