Skip to content

Commit

Permalink
TST: Ensure new test is not affected by other tests in the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellister-slac committed Feb 10, 2024
1 parent cacba85 commit 0898fe6
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions pydm/tests/test_main_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

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

Expand All @@ -11,14 +12,19 @@
@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)
clear_compiled_ui_file_cache() # Ensure other tests have not already compiled our test file before we start

qapp.make_main_window()
qapp.main_window.set_display_widget(display)
try:
display = Display(parent=None, ui_filename=test_ui_path)

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

# 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
# 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
finally:
clear_compiled_ui_file_cache()

0 comments on commit 0898fe6

Please sign in to comment.