Skip to content

Commit

Permalink
Only test Qt connection functionality when environment permits.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Jun 4, 2024
1 parent 43e2de5 commit 46cf9d1
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
21 changes: 21 additions & 0 deletions echo/qt/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
__all__ = [
"PYQT5_INSTALLED", "PYQT6_INSTALLED",
"PYSIDE2_INSTALLED", "PYSIDE6_INSTALLED",
"QTPY_INSTALLED", "QT_INSTALLED",
"SKIP_QT_TEST"
]

def package_installed(package):
try:
__import__(package)
return True
except ImportError:
return False

PYQT5_INSTALLED = package_installed("PyQt5")
PYQT6_INSTALLED = package_installed("PyQt6")
PYSIDE2_INSTALLED = package_installed("PySide2")
PYSIDE6_INSTALLED = package_installed("PySide6")
QTPY_INSTALLED = package_installed("qtpy")
QT_INSTALLED = PYQT5_INSTALLED or PYQT6_INSTALLED or PYSIDE2_INSTALLED or PYSIDE6_INSTALLED
SKIP_QT_TEST = not (QTPY_INSTALLED and QT_INSTALLED)
10 changes: 8 additions & 2 deletions echo/qt/tests/test_autoconnect.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from datetime import datetime

import pytest
from numpy import datetime64

from echo import CallbackProperty
from echo.qt.tests.helpers import SKIP_QT_TEST

if SKIP_QT_TEST:
pytest.skip(allow_module_level=True)

from qtpy import QtWidgets, QtGui
from qtpy.QtCore import QDateTime, Qt

from echo.qt.autoconnect import autoconnect_callbacks_to_qt
from echo import CallbackProperty
from echo.qt.connect import UserDataWrapper


Expand Down
10 changes: 8 additions & 2 deletions echo/qt/tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
from numpy import datetime64
from unittest.mock import MagicMock

from echo import CallbackProperty
from echo.qt.tests.helpers import SKIP_QT_TEST

if SKIP_QT_TEST:
pytest.skip(allow_module_level=True)

from qtpy import QtWidgets
from qtpy.QtCore import QDateTime, Qt

from echo import CallbackProperty
from echo.qt.connect import (connect_checkable_button, connect_datetime, connect_text,
connect_combo_data, connect_combo_text,
connect_float_text, connect_value, connect_button,
Expand All @@ -16,6 +20,8 @@

def test_connect_checkable_button():



class Test(object):
a = CallbackProperty()
b = CallbackProperty(True)
Expand Down
7 changes: 5 additions & 2 deletions echo/qt/tests/test_connect_combo_selection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import pytest
import numpy as np

from qtpy import QtWidgets

from echo.core import CallbackProperty
from echo.selection import SelectionCallbackProperty, ChoiceSeparator
from echo.qt.tests.helpers import SKIP_QT_TEST
if SKIP_QT_TEST:
pytest.skip(allow_module_level=True)

from qtpy import QtWidgets
from echo.qt.connect import connect_combo_selection


Expand Down
9 changes: 6 additions & 3 deletions echo/qt/tests/test_connect_list_selection.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pytest
import numpy as np

from qtpy import QtWidgets
from qtpy.QtCore import Qt

from echo.core import CallbackProperty
from echo.selection import SelectionCallbackProperty, ChoiceSeparator
from echo.qt.tests.helpers import SKIP_QT_TEST
if SKIP_QT_TEST:
pytest.skip(allow_module_level=True)

from qtpy import QtWidgets
from qtpy.QtCore import Qt
from echo.qt.connect import connect_list_selection


Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ changedir =
test: .tmp/{envname}
docs: doc
deps =
pyqt{510,511,512,513,514,515,63},pyside{513,514,515,63}: qtpy>=2.0
pyqt510: PyQt5==5.10.*
pyqt511: PyQt5==5.11.*
pyqt512: PyQt5==5.12.*
Expand Down

0 comments on commit 46cf9d1

Please sign in to comment.