Compare commits
19 Commits
tests
...
segfault-d
| Author | SHA1 | Date | |
|---|---|---|---|
| 72c51c5744 | |||
| 1e203873c9 | |||
| a80b568894 | |||
| 2edc68151d | |||
| aa03291e42 | |||
| 5d97dd6224 | |||
| bed086f95f | |||
| aa79f1b0a1 | |||
| bbb6d6c00c | |||
| c6f034f2d3 | |||
| a624cf37a4 | |||
| efd023ae3a | |||
| d65e97c9a7 | |||
| 4fcc10f3da | |||
| c781601246 | |||
| 831b03a744 | |||
| b94294b579 | |||
| b14f6e68b4 | |||
| 7d169fdd53 |
@@ -1,29 +1,62 @@
|
||||
stages:
|
||||
- Test
|
||||
- Tests
|
||||
- OptionalTests
|
||||
|
||||
.install-grum-test: &install-grum-test
|
||||
- pip install pytest pytest-random-order pytest-cov
|
||||
- pip install -e ./
|
||||
- apt-get update
|
||||
- apt-get install -y ffmpeg libnss3 libxcomposite1 libxtst6
|
||||
|
||||
tests:
|
||||
stage: Test
|
||||
stage: Tests
|
||||
image: python:3.8
|
||||
variables:
|
||||
QT_QPA_PLATFORM: "offscreen"
|
||||
XDG_RUNTIME_DIR: "/tmp/runtime-root"
|
||||
|
||||
PYTHONFAULTHANDLER: 1
|
||||
script:
|
||||
- pip install pytest pytest-random-order pytest-cov
|
||||
- pip install -e ./
|
||||
- pip install PyQtWebEngine
|
||||
|
||||
- apt-get update
|
||||
- apt-get install -y ffmpeg libnss3 libxcomposite1 libxtst6
|
||||
|
||||
# - python -m unittest discover -f ./tests
|
||||
# - coverage run --source=./grum -m unittest discover -f ./tests
|
||||
- coverage run --source=./grum -m pytest ./tests
|
||||
- *install-grum-test
|
||||
- coverage run --source=./grum -m pytest ./tests --junitxml=report-junit.xml
|
||||
- coverage report
|
||||
- coverage xml
|
||||
|
||||
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
cobertura: coverage.xml
|
||||
junit: report-junit.xml
|
||||
|
||||
tests-3.6:
|
||||
stage: OptionalTests
|
||||
image: python:3.6
|
||||
needs: ["tests"]
|
||||
allow_failure: true
|
||||
variables:
|
||||
QT_QPA_PLATFORM: "offscreen"
|
||||
XDG_RUNTIME_DIR: "/tmp/runtime-root"
|
||||
PYTHONFAULTHANDLER: 1
|
||||
script:
|
||||
- *install-grum-test
|
||||
- pytest ./tests
|
||||
|
||||
tests-3.7:
|
||||
extends: "tests-3.6"
|
||||
image: python:3.7
|
||||
|
||||
#tests-3.8:
|
||||
# extends: "tests-3.6"
|
||||
# image: python:3.8
|
||||
|
||||
tests-3.9:
|
||||
extends: "tests-3.6"
|
||||
image: python:3.9
|
||||
|
||||
tests-3.10:
|
||||
extends: "tests-3.6"
|
||||
image: python:3.10
|
||||
|
||||
tests-3.11:
|
||||
extends: "tests-3.6"
|
||||
image: python:3.11
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ class MainWindow(QMainWindow):
|
||||
rst.start()
|
||||
rst.server.register_function(self.new_plot)
|
||||
rst.server.register_function(self.append_data)
|
||||
rst.server.register_function(self.extend_data)
|
||||
rst.server.register_function(self.set_data)
|
||||
|
||||
self.sig_make_new_plot.connect(self.on_make_new_plot)
|
||||
|
||||
@@ -116,14 +118,27 @@ class MainWindow(QMainWindow):
|
||||
item = self.lst.get(name)
|
||||
desc = item.value
|
||||
desc.append(point)
|
||||
alarm = True
|
||||
for sub in self.mdi.subWindowList():
|
||||
if name in sub.plots:
|
||||
plot = sub.plots[name]
|
||||
plot.setData(*desc.data)
|
||||
alarm = False
|
||||
item.timestamps.modification.update()
|
||||
item.set_alarm(alarm)
|
||||
self.sync_item_and_plots(item)
|
||||
|
||||
def extend_data(self, name, data):
|
||||
"""
|
||||
Extend the current data of the (existing) plot <name>.by <data>
|
||||
The data is forwarded to the extend method of PlotDescription.
|
||||
"""
|
||||
item = self.lst.get(name)
|
||||
desc = item.value
|
||||
desc.extend(data)
|
||||
self.sync_item_and_plots(item)
|
||||
|
||||
def set_data(self, name, data):
|
||||
"""
|
||||
Set <data> as the data of the (existing) plot <name>.
|
||||
The data is assigned to the data attribute of PlotDescription.
|
||||
"""
|
||||
item = self.lst.get(name)
|
||||
desc = item.value
|
||||
desc.data = data
|
||||
self.sync_item_and_plots(item)
|
||||
|
||||
|
||||
# Signal callbacks
|
||||
@@ -196,6 +211,17 @@ class MainWindow(QMainWindow):
|
||||
self.lst.set(name, desc)
|
||||
return desc
|
||||
|
||||
def sync_item_and_plots(self, item):
|
||||
name, desc = item.key, item.value
|
||||
alarm = True
|
||||
for sub in self.mdi.subWindowList():
|
||||
if name in sub.plots:
|
||||
plot = sub.plots[name]
|
||||
plot.setData(*desc.data)
|
||||
alarm = False
|
||||
item.timestamps.modification.update()
|
||||
item.set_alarm(alarm)
|
||||
|
||||
def plot_single_item(self, item):
|
||||
item.timestamps.access.update()
|
||||
item.set_alarm(False)
|
||||
|
||||
@@ -14,12 +14,21 @@ class PlotDescription:
|
||||
def data(self):
|
||||
return (self.xs, self.ys)
|
||||
|
||||
@data.setter
|
||||
def data(self, value):
|
||||
self.xs, self.ys = value
|
||||
|
||||
|
||||
def append(self, xy):
|
||||
x, y = xy
|
||||
self.xs.append(x)
|
||||
self.ys.append(y)
|
||||
|
||||
def extend(self, data):
|
||||
xs, ys = data
|
||||
self.xs.extend(xs)
|
||||
self.ys.extend(ys)
|
||||
|
||||
|
||||
def make_plot(self, plotwidget, style):
|
||||
res = plotwidget.plot(self.xs, self.ys, name=self.name, **style)
|
||||
|
||||
@@ -16,4 +16,10 @@ class RPCClient(xrc.ServerProxy):
|
||||
return head + help
|
||||
|
||||
|
||||
def __dir__(self):
|
||||
d1 = super().__dir__()
|
||||
d2 = self.utils.info().keys()
|
||||
return [*d1, *d2]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
url = https://gitlab.psi.ch/augustin_s/grum
|
||||
project_urls =
|
||||
Bug Tracker = https://gitlab.psi.ch/augustin_s/grum/issues
|
||||
Bug Tracker = https://gitlab.psi.ch/augustin_s/grum/issues
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
License :: OSI Approved :: MIT License
|
||||
@@ -16,7 +16,7 @@ classifiers =
|
||||
package_dir =
|
||||
= .
|
||||
packages = find:
|
||||
python_requires = >=3.8
|
||||
python_requires = >=3.6
|
||||
|
||||
[options.packages.find]
|
||||
where = .
|
||||
|
||||
2
setup.py
2
setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup(
|
||||
install_requires=["pyqt5", "pyqtgraph", "h5py"],
|
||||
install_requires=["pyqt5", "pyqtgraph", "h5py", "PyQtWebEngine"],
|
||||
entry_points={"console_scripts": ["grum=grum:main"]},
|
||||
)
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
|
||||
|
||||
from grum.dictlist.dictlistwidget import DictListWidget
|
||||
from grum.menus.rclickmenu import RClickMenu
|
||||
|
||||
|
||||
|
||||
class DictListWidgetMock(DictListWidget):
|
||||
def __init__(self) -> None:
|
||||
self.items = {}
|
||||
self.nkeep = None
|
||||
|
||||
def get_DictListWidgetMock():
|
||||
return DictListWidgetMock()
|
||||
|
||||
# def test_defaults():
|
||||
# dlw = get_DictListWidgetMock()
|
||||
|
||||
# assert dlw.items == {}
|
||||
# assert dlw.nkeep == None
|
||||
|
||||
# def test_add_menu():
|
||||
# dlw = get_DictListWidgetMock()
|
||||
# dlw._add_menu()
|
||||
|
||||
# assert dlw.menu == RClickMenu(dlw)
|
||||
@@ -21,6 +21,7 @@ from grum.rpc import RPCServerThread
|
||||
class TestMainWin:
|
||||
|
||||
def setup_method(self):
|
||||
print("setup")
|
||||
self.app = QApplication(sys.argv)
|
||||
theme.apply(self.app)
|
||||
# ctrl_c.setup(self.app)
|
||||
@@ -29,8 +30,10 @@ class TestMainWin:
|
||||
|
||||
|
||||
def teardown_method(self):
|
||||
print("teardown")
|
||||
self.mw.rst.wait_for_stop()
|
||||
self.app.quit()
|
||||
print("app quit called")
|
||||
del self.mw
|
||||
del self.app
|
||||
|
||||
@@ -164,19 +167,6 @@ class TestMainWin:
|
||||
mw.on_plot_selected()
|
||||
mw.plot_multiple_items.assert_called_once_with([sine_item, cosine_item])
|
||||
|
||||
|
||||
def test_on_sort_by_name(self):
|
||||
mw = self.mw
|
||||
mw.lst = DictList()
|
||||
mw.new_plot("bb", {})
|
||||
mw.new_plot("dd", {})
|
||||
mw.new_plot("aa", {})
|
||||
mw.new_plot("cc", {})
|
||||
|
||||
assert mw.lst.lst.items == 111
|
||||
assert [key for key in mw.lst.lst.items.keys()] == ['bb', 'dd', 'aa', 'cc']
|
||||
mw.on_sort_by_name()
|
||||
assert mw.lst.lst.items == 111
|
||||
|
||||
def test_plot_single_item(self):
|
||||
mw = self.mw
|
||||
|
||||
@@ -15,13 +15,13 @@ class TestMDIArea:
|
||||
def setup_method(self):
|
||||
print("setup")
|
||||
self.app = QApplication(sys.argv)
|
||||
self.mw = MainWindow(add_examples=True)
|
||||
self.mw = MainWindow(add_examples=True, offline=True)
|
||||
self.mw.show()
|
||||
|
||||
|
||||
def teardown_method(self):
|
||||
print("teardown")
|
||||
self.mw.rst.wait_for_stop()
|
||||
# self.mw.rst.wait_for_stop()
|
||||
self.app.quit()
|
||||
print("app quit called")
|
||||
del self.mw
|
||||
|
||||
@@ -53,7 +53,7 @@ def test_make_plot():
|
||||
)
|
||||
app = QApplication(sys.argv)
|
||||
theme.apply(app)
|
||||
mw = MainWindow(add_examples=True)
|
||||
mw = MainWindow(add_examples=True, offline=True)
|
||||
|
||||
mdi_sub = MDISubPlot("mdi", pd)
|
||||
pw = pg.PlotWidget()
|
||||
|
||||
Reference in New Issue
Block a user