-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #888 from jbellister-slac/add_display_tests
TST: Add some test cases for loading python files as displays
- Loading branch information
Showing
4 changed files
with
87 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# A sample test file of a python class that does not inherit from PyDM's display, but we try to load as a display anyway | ||
from qtpy.QtCore import QObject | ||
|
||
|
||
class InvalidDisplayExample(QObject): | ||
""" A simple class that inherits from QObject only """ | ||
def __init__(self, parent=None): | ||
super().__init__(parent=parent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" This file is intended for use in Display related test files. """ | ||
import os | ||
from pydm import Display | ||
from pydm.widgets import PyDMPushButton, PyDMLabel | ||
# Ensure loading of modules in the same directory works as expected when this file is loaded as a PyDM Display | ||
import no_display_test_file | ||
|
||
|
||
class DisplayExample(Display): | ||
""" An example of a simple display that can be loaded by `load_py_file` in `display.py` """ | ||
def __init__(self, parent=None, args=None, macros=None): | ||
super().__init__(parent=parent, args=args, macros=macros) | ||
self.button = PyDMPushButton() | ||
self.button.clicked.connect(self.delete_widget) | ||
|
||
self.label = PyDMLabel(init_channel='TST:Val1') | ||
|
||
def print_file(self): | ||
print(f'{no_display_test_file}') | ||
|
||
def delete_widget(self): | ||
self.label.deleteLater() | ||
|
||
def ui_filename(self): | ||
return 'test.ui' | ||
|
||
def ui_filepath(self): | ||
return os.path.join(os.path.dirname(os.path.realpath(__file__)), self.ui_filename()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters