Skip to content
Snippets Groups Projects
Commit f477a591 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Add testing with pyqt5

parent c99955f8
No related branches found
No related tags found
1 merge request!129Add testing with pyqt5
Pipeline #88490 passed
...@@ -7,7 +7,12 @@ before_script: ...@@ -7,7 +7,12 @@ before_script:
- apt-get install --yes build-essential cmake libfmt-dev pybind11-dev graphviz python3-pyqt5 xvfb xdg-utils lcov - apt-get install --yes build-essential cmake libfmt-dev pybind11-dev graphviz python3-pyqt5 xvfb xdg-utils lcov
- python -m pip install --upgrade pip - python -m pip install --upgrade pip
- python --version - python --version
- pip install pytest pytest-cov sphinx furo numpydoc pytest-xvfb pytest-qt setuptools_scm sphinx-qt-documentation pytest-xdist pytest-mpl - pip install -r requirements.txt
- pip install -r requirements_doc.txt
- pip install -r requirements_test.txt
- pip install $QT_API
- export PYTEST_QT_API=$QT_API
- export QT_API=$QT_API
# - export CXXFLAGS='--coverage' # - export CXXFLAGS='--coverage'
- pip install -ve . - pip install -ve .
# Move file, but should be handled by installation # Move file, but should be handled by installation
...@@ -17,7 +22,7 @@ before_script: ...@@ -17,7 +22,7 @@ before_script:
.run-test: .run-test:
stage: test stage: test
script: script:
- pytest --cov=b_asic --cov-report=xml:cov.xml --cov-report=term --color=yes test --mpl - pytest --cov=b_asic --cov-report=xml:cov.xml --cov-report=term --color=yes test --mpl --timeout=20 --durations=10
# - lcov --capture --directory . --output-file coverage.info # - lcov --capture --directory . --output-file coverage.info
# - lcov --output-file coverage.info --extract coverage.info $PWD/src/'*' $PWD/b_asic/'*' # - lcov --output-file coverage.info --extract coverage.info $PWD/src/'*' $PWD/b_asic/'*'
# - lcov --list coverage.info # - lcov --list coverage.info
...@@ -30,19 +35,60 @@ before_script: ...@@ -30,19 +35,60 @@ before_script:
coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/ coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/
run-test-3.8: run-test-3.8-pyside2:
variables:
QT_API: pyside2
image: python:3.8 image: python:3.8
extends: ".run-test" extends: ".run-test"
run-test-3.9: run-test-3.8-pyqt5:
variables:
QT_API: pyqt5
image: python:3.8
extends: ".run-test"
run-test-3.9-pyside2:
variables:
QT_API: pyside2
image: python:3.9
extends: ".run-test"
run-test-3.9-pyqt5:
variables:
QT_API: pyqt5
image: python:3.9 image: python:3.9
extends: ".run-test" extends: ".run-test"
run-test-3.10: run-test-3.10-pyside2:
variables:
QT_API: pyside2
image: python:3.10 image: python:3.10
extends: ".run-test" extends: ".run-test"
run-test-3.10-pyqt5:
variables:
QT_API: pyqt5
image: python:3.10
extends: ".run-test"
# Seemingly works with Qt6, but tests stall on closing scheduler GUI due to modal dialog(?)
#run-test-3.10-pyside6:
# variables:
# QT_API: pyside6
# image: python:3.10
# extends: ".run-test"
# allow_failure: true
#
#run-test-3.10-pyqt6:
# variables:
# QT_API: pyqt6
# image: python:3.10
# extends: ".run-test"
# allow_failure: true
run-doc-test: run-doc-test:
variables:
QT_API: pyside2
image: python:3.10 image: python:3.10
stage: test stage: test
script: script:
...@@ -53,6 +99,8 @@ run-doc-test: ...@@ -53,6 +99,8 @@ run-doc-test:
# extends: ".run-test" # extends: ".run-test"
pages: pages:
variables:
QT_API: pyqt5
stage: deploy stage: deploy
image: python:3.10 image: python:3.10
script: script:
......
...@@ -83,8 +83,9 @@ class DragButton(QPushButton): ...@@ -83,8 +83,9 @@ class DragButton(QPushButton):
def mousePressEvent(self, event): def mousePressEvent(self, event):
if event.button() == Qt.MouseButton.LeftButton: if event.button() == Qt.MouseButton.LeftButton:
self._m_press = True self._m_press = True
self._mouse_press_pos = event.pos() pos = event.pos()
self._mouse_move_pos = event.pos() self._mouse_press_pos = pos
self._mouse_move_pos = pos
super().mousePressEvent(event) super().mousePressEvent(event)
......
...@@ -16,6 +16,7 @@ from qtpy.QtWidgets import ( ...@@ -16,6 +16,7 @@ from qtpy.QtWidgets import (
QAction, QAction,
QApplication, QApplication,
QFileDialog, QFileDialog,
QGraphicsItem,
QGraphicsScene, QGraphicsScene,
QGraphicsTextItem, QGraphicsTextItem,
QGraphicsView, QGraphicsView,
...@@ -527,7 +528,7 @@ class MainWindow(QMainWindow): ...@@ -527,7 +528,7 @@ class MainWindow(QMainWindow):
attr_button_scene.moveBy( attr_button_scene.moveBy(
int(self.scene.width() / 4), int(self.scene.height() / 4) int(self.scene.width() / 4), int(self.scene.height() / 4)
) )
attr_button_scene.setFlag(attr_button_scene.ItemIsSelectable, True) attr_button_scene.setFlag(QGraphicsItem.ItemIsSelectable, True)
operation_label = QGraphicsTextItem(op.name, attr_button_scene) operation_label = QGraphicsTextItem(op.name, attr_button_scene)
if not self.is_show_names: if not self.is_show_names:
operation_label.setOpacity(0) operation_label.setOpacity(0)
......
...@@ -9,7 +9,7 @@ from math import pi, sin ...@@ -9,7 +9,7 @@ from math import pi, sin
from typing import List, Optional, Union from typing import List, Optional, Union
# QGraphics and QPainter imports # QGraphics and QPainter imports
from qtpy.QtCore import QPoint, QPointF, Qt from qtpy.QtCore import QPointF, Qt
from qtpy.QtGui import QBrush, QPen, QPolygonF from qtpy.QtGui import QBrush, QPen, QPolygonF
from qtpy.QtWidgets import ( from qtpy.QtWidgets import (
QGraphicsItem, QGraphicsItem,
...@@ -318,7 +318,7 @@ class AxesItem(QGraphicsItemGroup): ...@@ -318,7 +318,7 @@ class AxesItem(QGraphicsItemGroup):
self._append_x_tick() self._append_x_tick()
pos = self._x_ledger[-1].pos() pos = self._x_ledger[-1].pos()
self._x_ledger[-1].setPos( self._x_ledger[-1].setPos(
pos + QPoint(self._width, 0) pos + QPointF(self._width, 0)
) # move timeline ) # move timeline
# y-axis # y-axis
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property> </property>
<property name="renderHints"> <property name="renderHints">
<set>QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing</set> <set>QPainter::Antialiasing|QPainter::TextAntialiasing</set>
</property> </property>
<property name="viewportUpdateMode"> <property name="viewportUpdateMode">
<enum>QGraphicsView::FullViewportUpdate</enum> <enum>QGraphicsView::FullViewportUpdate</enum>
...@@ -126,7 +126,6 @@ ...@@ -126,7 +126,6 @@
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
...@@ -158,7 +157,6 @@ ...@@ -158,7 +157,6 @@
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
......
...@@ -55,8 +55,7 @@ class Ui_MainWindow(object): ...@@ -55,8 +55,7 @@ class Ui_MainWindow(object):
QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop
) )
self.view.setRenderHints( self.view.setRenderHints(
QtGui.QPainter.HighQualityAntialiasing QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing
| QtGui.QPainter.TextAntialiasing
) )
self.view.setViewportUpdateMode( self.view.setViewportUpdateMode(
QtWidgets.QGraphicsView.FullViewportUpdate QtWidgets.QGraphicsView.FullViewportUpdate
...@@ -89,7 +88,6 @@ class Ui_MainWindow(object): ...@@ -89,7 +88,6 @@ class Ui_MainWindow(object):
item = QtWidgets.QTableWidgetItem() item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont() font = QtGui.QFont()
font.setBold(True) font.setBold(True)
font.setWeight(75)
item.setFont(font) item.setFont(font)
brush = QtGui.QBrush(QtGui.QColor(160, 160, 164)) brush = QtGui.QBrush(QtGui.QColor(160, 160, 164))
brush.setStyle(QtCore.Qt.SolidPattern) brush.setStyle(QtCore.Qt.SolidPattern)
...@@ -108,7 +106,6 @@ class Ui_MainWindow(object): ...@@ -108,7 +106,6 @@ class Ui_MainWindow(object):
item = QtWidgets.QTableWidgetItem() item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont() font = QtGui.QFont()
font.setBold(True) font.setBold(True)
font.setWeight(75)
item.setFont(font) item.setFont(font)
brush = QtGui.QBrush(QtGui.QColor(160, 160, 164)) brush = QtGui.QBrush(QtGui.QColor(160, 160, 164))
brush.setStyle(QtCore.Qt.SolidPattern) brush.setStyle(QtCore.Qt.SolidPattern)
......
...@@ -10,7 +10,7 @@ requires-python = ">=3.8" ...@@ -10,7 +10,7 @@ requires-python = ">=3.8"
dependencies = [ dependencies = [
"numpy", "numpy",
"pybind11>=2.3.0", "pybind11>=2.3.0",
"pyside2", # "pyside2",
"qtpy", "qtpy",
"graphviz>=0.19", "graphviz>=0.19",
"matplotlib", "matplotlib",
...@@ -22,7 +22,7 @@ classifiers = [ ...@@ -22,7 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", # "Programming Language :: Python :: 3.11",
"Programming Language :: C++", "Programming Language :: C++",
"License :: OSI Approved :: MIT License", "License :: OSI Approved :: MIT License",
"Operating System :: OS Independent", "Operating System :: OS Independent",
...@@ -56,7 +56,7 @@ skip-string-normalization = true ...@@ -56,7 +56,7 @@ skip-string-normalization = true
preview = true preview = true
line-length = 79 line-length = 79
exclude = [ exclude = [
"test/test_gui" "test/test_gui", "b_asic/scheduler_gui/ui_main_window.py"
] ]
[tool.isort] [tool.isort]
...@@ -64,7 +64,7 @@ profile = "black" ...@@ -64,7 +64,7 @@ profile = "black"
line_length = 79 line_length = 79
src_paths = ["b_asic", "test"] src_paths = ["b_asic", "test"]
skip = [ skip = [
"test/test_gui" "test/test_gui", "b_asic/scheduler_gui/ui_main_window.py"
] ]
......
...@@ -2,5 +2,6 @@ pytest ...@@ -2,5 +2,6 @@ pytest
pytest-cov pytest-cov
pytest-qt pytest-qt
pytest-mpl pytest-mpl
pytest-timeout
pytest-xvfb pytest-xvfb
pytest-xdist pytest-xdist
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment